-
-
Save MarcinusX/4e6354fa9cd9e396e9a1f404055d70bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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