Skip to content

Instantly share code, notes, and snippets.

@MarcinusX
Created January 13, 2019 08:48
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/cfb13d134086998ada7df85a48d7983a to your computer and use it in GitHub Desktop.
Save MarcinusX/cfb13d134086998ada7df85a48d7983a to your computer and use it in GitHub Desktop.
class _MainPageState extends State<MainPage> with SingleTickerProviderStateMixin {
int points = 0; //<-- add points field
...
@override
Widget build(BuildContext context) {
return Material(
child: Stack(
fit: StackFit.passthrough,
children: <Widget>[
Image.asset(...),
Row(...),
_drawPoints(), //<-- add points widget on top of stack
],
),
);
}
void _onTap(Note note) {
setState(() {
note.state = NoteState.tapped;
++points; //<-- increase number of points
});
}
_drawPoints() { //<-- draw points
return Align(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(top: 32.0),
child: Text(
"$points",
style: TextStyle(color: Colors.red, fontSize: 60),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment