Skip to content

Commit

Permalink
show processing on start quiz
Browse files Browse the repository at this point in the history
  • Loading branch information
lohanidamodar committed Jun 4, 2019
1 parent 7893788 commit 1c72040
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/ui/widgets/quiz_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ class QuizOptionsDialog extends StatefulWidget {
class _QuizOptionsDialogState extends State<QuizOptionsDialog> {
int _noOfQuestions;
String _difficulty;
bool processing;

@override
void initState() {
super.initState();
_noOfQuestions = 10;
_difficulty = "easy";
processing = false;
}

@override
Expand Down Expand Up @@ -114,7 +116,7 @@ class _QuizOptionsDialogState extends State<QuizOptionsDialog> {
),
),
SizedBox(height: 20.0),
RaisedButton(
processing ? CircularProgressIndicator() : RaisedButton(
child: Text("Start Quiz"),
onPressed: _startQuiz,
),
Expand All @@ -137,6 +139,9 @@ class _QuizOptionsDialogState extends State<QuizOptionsDialog> {
}

void _startQuiz() async {
setState(() {
processing=true;
});
try {
List<Question> questions = await getQuestions(widget.category, _noOfQuestions, _difficulty);
Navigator.pop(context);
Expand All @@ -152,5 +157,8 @@ class _QuizOptionsDialogState extends State<QuizOptionsDialog> {
}catch(e){
print(e.message);
}
setState(() {
processing=false;
});
}
}

0 comments on commit 1c72040

Please sign in to comment.