Instantly share code, notes, and snippets.

@MarcinusX MarcinusX/line.dart Secret
Created Jan 13, 2019

Embed
What would you like to do?
class Line extends AnimatedWidget { //<--- Use AnimatedWidget
final int lineNumber;
final List<Note> currentNotes;
const Line(
{Key key,
this.currentNotes,
this.lineNumber,
Animation<double> animation}) //<-- Add animation to constructor
: super(key: key, listenable: animation); //<-- And pass it to super constructor
@override
Widget build(BuildContext context) {
Animation<double> animation = super.listenable; //<--get the animation
...
//map notes to widgets
List<Widget> tiles = thisLineNotes.map((note) {
//specify note distance from top
int index = currentNotes.indexOf(note);
double offset = (3 - index + animation.value) * tileHeight; //<-- add animation.value to offset
...
}).toList();
return SizedBox.expand(
child: Stack(
children: tiles,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment