From c0eb133c0a333b8487f048122e7849ab9cf7ed48 Mon Sep 17 00:00:00 2001 From: nathanAndrinoid Date: Mon, 8 Jun 2026 01:14:01 +0000 Subject: [PATCH] always answer --- lib/widgets/spelling_question_tile.dart | 37 ++++++++----------- test/widgets/spelling_question_tile_test.dart | 15 +------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/lib/widgets/spelling_question_tile.dart b/lib/widgets/spelling_question_tile.dart index 3ac1e70..e4c3b49 100644 --- a/lib/widgets/spelling_question_tile.dart +++ b/lib/widgets/spelling_question_tile.dart @@ -202,16 +202,9 @@ class _SpellingQuestionTileState extends State { setState(() { _answerCorrect = correct; _showingFeedback = true; + _awaitingNext = true; }); - - await Future.delayed(const Duration(seconds: 1)); - if (mounted) { - setState(() { - _showingFeedback = false; - _awaitingNext = true; - }); - _tileFocusNode.requestFocus(); - } + _tileFocusNode.requestFocus(); } Future _triggerNextQuestion() async { @@ -296,20 +289,20 @@ class _SpellingQuestionTileState extends State { ), ), const SizedBox(height: 28), - if (feedbackWord != null && feedbackColor != null) - Padding( - padding: const EdgeInsets.symmetric(vertical: 24), - child: Text( - feedbackWord, - key: const Key('spelling-feedback-word'), - textAlign: TextAlign.center, - style: Theme.of(context).textTheme.headlineMedium?.copyWith( - color: feedbackColor, - fontWeight: FontWeight.w700, - ), + if (_awaitingNext) ...[ + if (feedbackWord != null && feedbackColor != null) + Padding( + padding: const EdgeInsets.symmetric(vertical: 24), + child: Text( + feedbackWord, + key: const Key('spelling-feedback-word'), + textAlign: TextAlign.center, + style: Theme.of(context).textTheme.headlineMedium?.copyWith( + color: feedbackColor, + fontWeight: FontWeight.w700, + ), + ), ), - ) - else if (_awaitingNext) ...[ const SizedBox(height: 24), FilledButton( key: const Key('spelling-next-question'), diff --git a/test/widgets/spelling_question_tile_test.dart b/test/widgets/spelling_question_tile_test.dart index 55e1401..3d497bd 100644 --- a/test/widgets/spelling_question_tile_test.dart +++ b/test/widgets/spelling_question_tile_test.dart @@ -36,11 +36,6 @@ void main() { ); expect(feedback.data, 'colour'); expect(feedback.style?.color, AppColors.success); - - await tester.pump(const Duration(seconds: 1)); - await tester.pump(); - - expect(find.byKey(const Key('spelling-feedback-word')), findsNothing); expect(find.byKey(const Key('spelling-next-question')), findsOneWidget); expect(submitCount, 0); @@ -76,10 +71,6 @@ void main() { ); expect(feedback.data, 'colour'); expect(feedback.style?.color, AppColors.error); - - await tester.pump(const Duration(seconds: 1)); - await tester.pump(); - expect(find.byKey(const Key('spelling-next-question')), findsOneWidget); }); @@ -111,12 +102,8 @@ void main() { expect(submitCount, 0); expect(find.byKey(const Key('spelling-feedback-word')), findsOneWidget); - - await tester.pump(const Duration(seconds: 1)); - await tester.pump(); - expect(find.byKey(const Key('spelling-next-question')), findsOneWidget); - + await tester.sendKeyEvent(LogicalKeyboardKey.enter); await tester.pump();