Instantly share code, notes, and snippets.

@MarcinusX MarcinusX/main.dart Secret
Created Jan 13, 2019

Embed
What would you like to do?
class _MainPageState extends State<MainPage> with SingleTickerProviderStateMixin {
bool hasStarted = false;
...
@override
void initState() {
...
animationController.forward(); //<-- remove this line
}
void _onTap(Note note) {
bool areAllPreviousTapped = notes
.sublist(0, note.orderNumber)
.every((n) => n.state == NoteState.tapped);
if (areAllPreviousTapped) {
if (!hasStarted) { //<-- If game hasn't started
setState(() => hasStarted = true); //<-- Set flag to true
animationController.forward(); //<-- And start the animation
}
setState(() {
note.state = NoteState.tapped;
++points;
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment