-
-
Save MarcinusX/1f66f01fefe3520126df1ada2994a9b0 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 StatelessWidget { | |
final int lineNumber; | |
final List<Note> currentNotes; | |
const Line({Key key, this.currentNotes, this.lineNumber}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
//get heights | |
double height = MediaQuery.of(context).size.height; | |
double tileHeight = height / 4; | |
//get only notes for that line | |
List<Note> thisLineNotes = | |
currentNotes.where((note) => note.line == lineNumber).toList(); | |
//map notes to widgets | |
List<Widget> tiles = thisLineNotes.map((note) { | |
//specify note distance from top | |
int index = currentNotes.indexOf(note); | |
double offset = (3 - index) * tileHeight; | |
return Transform.translate( | |
offset: Offset(0, offset), | |
child: Tile( | |
height: tileHeight, | |
state: note.state, | |
), | |
); | |
}).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