Skip to content

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 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
You can’t perform that action at this time.