Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created January 13, 2019 06:35
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/1f66f01fefe3520126df1ada2994a9b0 to your computer and use it in GitHub Desktop.
Save MarcinusX/1f66f01fefe3520126df1ada2994a9b0 to your computer and use it in GitHub Desktop.
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