Fixed dialog box at the end of practice

This commit is contained in:
BroodjeAap 2020-10-27 21:25:53 +01:00
parent a0ce8e9230
commit edf2556752

View file

@ -157,10 +157,8 @@ class _MonthPracticeState extends State<MonthPracticePage> {
); );
} }
Future _finishedPractice() { SimpleDialog finishedPracticeDialog() {
showDialog( return SimpleDialog(
context: context,
child: SimpleDialog(
title: Text("Practice Complete!"), title: Text("Practice Complete!"),
contentPadding: EdgeInsets.all(50), contentPadding: EdgeInsets.all(50),
children: <Widget>[ children: <Widget>[
@ -198,7 +196,6 @@ class _MonthPracticeState extends State<MonthPracticePage> {
] ]
), ),
] ]
)
); );
} }
@ -261,13 +258,17 @@ class _MonthPracticeState extends State<MonthPracticePage> {
} }
_count += 1; _count += 1;
answers.add(MonthPracticeAnswer(_month, answer)); answers.add(MonthPracticeAnswer(_month, answer));
if((_startCount - _count) == 0) {
_finishedPractice();
Navigator.pop(context);
return;
}
setState(() => { setState(() => {
_month = Months.getFromInt(_random.nextInt(Months.length)) _month = Months.getFromInt(_random.nextInt(Months.length))
}); });
if((_startCount - _count) == 0) {
showDialog(
context: context,
child: finishedPracticeDialog()
).then((val) {
Navigator.pop(context);
});
return;
}
} }
} }