diff --git a/lib/learn.dart b/lib/learn.dart index b1d6af0..b03de55 100644 --- a/lib/learn.dart +++ b/lib/learn.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:ju_learn/main.dart'; @@ -12,6 +14,7 @@ class QuizPage extends StatefulWidget { } class _QuizPageState extends State { + int runSeed = Random().nextInt(0xffffff); int run = 0; Question _currentQuestion = Question("Dummy", ["Dummy aws"], 0, "dummy"); int askState = -1; @@ -108,28 +111,32 @@ class _QuizPageState extends State { ), ), const SizedBox(height: 20.0), - ..._currentQuestion.answers.map( - (option) { - return Container( - margin: const EdgeInsets.symmetric(vertical: 8.0), - child: FilledButton( - onPressed: () => askState == -1 - ? _checkAnswer( - _currentQuestion.answers.indexOf(option), - ) - : _nextQuestion(), - style: FilledButton.styleFrom( - padding: const EdgeInsets.all(16.0), - backgroundColor: askState == -1 - ? null - : (_currentQuestion.correct == - _currentQuestion.answers.indexOf(option) - ? Colors.green - : Colors.red), - ), - child: Text(option))); - }, - ), + ...() { + var l = _currentQuestion.answers.map( + (option) { + return Container( + margin: const EdgeInsets.symmetric(vertical: 8.0), + child: FilledButton( + onPressed: () => askState == -1 + ? _checkAnswer( + _currentQuestion.answers.indexOf(option), + ) + : _nextQuestion(), + style: FilledButton.styleFrom( + padding: const EdgeInsets.all(16.0), + backgroundColor: askState == -1 + ? null + : (_currentQuestion.correct == + _currentQuestion.answers.indexOf(option) + ? Colors.green + : Colors.red), + ), + child: Text(option))); + }, + ).toList(); + l.shuffle(Random(run + runSeed)); + return l; + }(), if (askState != -1) Text( _currentQuestion.explanation,