Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created January 13, 2019 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarcinusX/4e6354fa9cd9e396e9a1f404055d70bb to your computer and use it in GitHub Desktop.
Save MarcinusX/4e6354fa9cd9e396e9a1f404055d70bb to your computer and use it in GitHub Desktop.
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