From 785591271d2b76c25ed7daad89793a91ef26ee7a Mon Sep 17 00:00:00 2001 From: NamrataCSalvi <147251955+NamrataCSalvi@users.noreply.github.com> Date: Fri, 31 May 2024 19:37:29 +0530 Subject: [PATCH 1/9] added game based test after learning modules added fun mcq tests after animals,birds,flowers,occupations,planets,parts modules --- lib/pages/main_home.dart | 2 + lib/pages/modules/animals.dart | 12 ++ lib/pages/modules/animals_test.dart | 220 ++++++++++++++++++++ lib/pages/modules/birds.dart | 12 ++ lib/pages/modules/birds_test.dart | 241 ++++++++++++++++++++++ lib/pages/modules/colours.dart | 3 +- lib/pages/modules/flowers.dart | 21 +- lib/pages/modules/flowers_test.dart | 216 ++++++++++++++++++++ lib/pages/modules/occupation.dart | 12 ++ lib/pages/modules/occupations_test.dart | 226 ++++++++++++++++++++ lib/pages/modules/parts.dart | 17 ++ lib/pages/modules/parts_test.dart | 261 ++++++++++++++++++++++++ lib/pages/modules/planets.dart | 16 +- lib/pages/modules/planets_test.dart | 206 +++++++++++++++++++ lib/utils/const_dimensions.dart | 2 + lib/utils/route/routes.dart | 2 +- 16 files changed, 1462 insertions(+), 7 deletions(-) create mode 100644 lib/pages/modules/animals_test.dart create mode 100644 lib/pages/modules/birds_test.dart create mode 100644 lib/pages/modules/flowers_test.dart create mode 100644 lib/pages/modules/occupations_test.dart create mode 100644 lib/pages/modules/parts_test.dart create mode 100644 lib/pages/modules/planets_test.dart diff --git a/lib/pages/main_home.dart b/lib/pages/main_home.dart index 3c38b3d..22beda9 100644 --- a/lib/pages/main_home.dart +++ b/lib/pages/main_home.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use + import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/lib/pages/modules/animals.dart b/lib/pages/modules/animals.dart index 81fe262..d80aae1 100644 --- a/lib/pages/modules/animals.dart +++ b/lib/pages/modules/animals.dart @@ -8,6 +8,7 @@ import 'package:learn/models/animal_model.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; +import 'animals_test.dart'; class AnimalsPage extends StatelessWidget { @@ -25,6 +26,17 @@ class AnimalsPage extends StatelessWidget { AppConstants.animal, style: TextStyle(fontWeight: FontWeight.bold), ), + actions: [ + IconButton( + icon: const Icon(Icons.assessment), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const AnimalsTestPage()), + ); + }, + ), + ], ), body: ListView.builder( itemCount: AppConstants.animals.length, diff --git a/lib/pages/modules/animals_test.dart b/lib/pages/modules/animals_test.dart new file mode 100644 index 0000000..bbf37ad --- /dev/null +++ b/lib/pages/modules/animals_test.dart @@ -0,0 +1,220 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class AnimalQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + AnimalQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class AnimalsTestPage extends StatefulWidget { + const AnimalsTestPage({Key? key}) : super(key: key); + + @override + _AnimalsTestPageState createState() => _AnimalsTestPageState(); +} + +class _AnimalsTestPageState extends State { + List questions = [ + AnimalQuestion( + imageAsset: 'assets/images/animal/lion.svg', + options: ['Lion', 'Tiger', 'Leopard', 'Cheetah'], + correctAnswer: 'Lion', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/elephant.svg', + options: ['Rhino', 'Hippo', 'Elephant', 'Giraffe'], + correctAnswer: 'Elephant', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/bear.svg', + options: ['Wolf', 'Fox', 'Bear', 'Dog'], + correctAnswer: 'Bear', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/cat.svg', + options: ['Dog', 'Cat', 'Rabbit', 'Squirrel'], + correctAnswer: 'Cat', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/cow.svg', + options: ['Goat', 'Sheep', 'Buffalo', 'Cow'], + correctAnswer: 'Cow', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/deer.svg', + options: ['Deer', 'Moose', 'Antelope', 'Elk'], + correctAnswer: 'Deer', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/dog.svg', + options: ['Wolf', 'Dog', 'Fox', 'Coyote'], + correctAnswer: 'Dog', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/fox.svg', + options: ['Wolf', 'Dog', 'Coyote', 'Fox'], + correctAnswer: 'Fox', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/giraffe.svg', + options: ['Giraffe', 'Elephant', 'Zebra', 'Camel'], + correctAnswer: 'Giraffe', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/monkey.svg', + options: ['Gorilla', 'Chimpanzee', 'Monkey', 'Baboon'], + correctAnswer: 'Monkey', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/pig.svg', + options: ['Pig', 'Boar', 'Hog', 'Warthog'], + correctAnswer: 'Pig', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/rabbit.svg', + options: ['Hare', 'Squirrel', 'Guinea Pig', 'Rabbit'], + correctAnswer: 'Rabbit', + ), + ]; + + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + AnimalQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Animals Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, // Random color + ), + child: Center( + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/birds.dart b/lib/pages/modules/birds.dart index df80096..2c6f66e 100644 --- a/lib/pages/modules/birds.dart +++ b/lib/pages/modules/birds.dart @@ -8,6 +8,7 @@ import 'package:learn/models/bird_model.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; +import 'birds_test.dart'; class BirdsPage extends StatelessWidget { @@ -24,6 +25,17 @@ class BirdsPage extends StatelessWidget { AppConstants.bird, style: TextStyle(fontWeight: FontWeight.bold), ), + actions: [ + IconButton( + icon: const Icon(Icons.assessment), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const BirdsTestPage()), + ); + }, + ), + ], ), body: Center( child: BirdWidget( diff --git a/lib/pages/modules/birds_test.dart b/lib/pages/modules/birds_test.dart new file mode 100644 index 0000000..ba84e77 --- /dev/null +++ b/lib/pages/modules/birds_test.dart @@ -0,0 +1,241 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class BirdQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + BirdQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class BirdsTestPage extends StatefulWidget { + const BirdsTestPage({Key? key}) : super(key: key); + + @override + _AnimalsTestPageState createState() => _AnimalsTestPageState(); +} + +class _AnimalsTestPageState extends State { + List questions = [ + BirdQuestion( + imageAsset: 'assets/images/birds/bagula.svg', + options: ['Bagula', 'Bulbul', 'Crow', 'Duck'], + correctAnswer: 'Bagula', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/bulbul.svg', + options: ['Eagle', 'Goose', 'Bulbul', 'Hen'], + correctAnswer: 'Bulbul', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/crow.svg', + options: ['Koel', 'Maina', 'Crow', 'Ostrich'], + correctAnswer: 'Crow', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/duck.svg', + options: ['Owl', 'Parrot', 'Pigeon', 'Duck'], + correctAnswer: 'Duck', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/eagle.svg', + options: ['Eagle', 'Sparrow', 'Swan', 'Vulture'], + correctAnswer: 'Eagle', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/goose.svg', + options: ['Crow', 'Goose', 'Hen', 'Koel'], + correctAnswer: 'Goose', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/hen.svg', + options: ['Maina', 'Ostrich', 'Hen', 'Parrot'], + correctAnswer: 'Hen', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/koel.svg', + options: ['Pigeon', 'Koel', 'Sparrow', 'Swan'], + correctAnswer: 'Koel', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/maina.svg', + options: ['Vulture', 'Maina', 'Eagle', 'Goose'], + correctAnswer: 'Maina', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/ostrich.svg', + options: ['Duck', 'Ostrich', 'Owl', 'Parrot'], + correctAnswer: 'Ostrich', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/owl.svg', + options: ['Pigeon', 'Owl', 'Sparrow', 'Swan'], + correctAnswer: 'Owl', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/parrot.svg', + options: ['Vulture', 'Bagula', 'Parrot', 'Bulbul'], + correctAnswer: 'Parrot', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/pigeon.svg', + options: ['Crow', 'Duck', 'Pigeon', 'Eagle'], + correctAnswer: 'Pigeon', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/sparrow.svg', + options: ['Goose', 'Hen', 'Sparrow', 'Koel'], + correctAnswer: 'Sparrow', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/swan.svg', + options: ['Maina', 'Ostrich', 'Swan', 'Owl'], + correctAnswer: 'Swan', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/vulture.svg', + options: ['Parrot', 'Pigeon', 'Vulture', 'Sparrow'], + correctAnswer: 'Vulture', + ), +]; + + + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + BirdQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Animals Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, // Random color + ), + child: Center( + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/colours.dart b/lib/pages/modules/colours.dart index 5c407ab..311b137 100644 --- a/lib/pages/modules/colours.dart +++ b/lib/pages/modules/colours.dart @@ -4,7 +4,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/utils/assets_path.dart'; -import '../../utils/const_dimensions.dart'; import 'package:learn/models/colours_model.dart'; class ColoursPage extends StatefulWidget { @@ -135,7 +134,7 @@ class _ColoursPageState extends State { children: [ GestureDetector( onTap: _navigateToNextColour, - child: Container( + child: SizedBox( width: double.infinity, height: 300, child: SvgPicture.asset( diff --git a/lib/pages/modules/flowers.dart b/lib/pages/modules/flowers.dart index 075f0d2..7b7e442 100644 --- a/lib/pages/modules/flowers.dart +++ b/lib/pages/modules/flowers.dart @@ -1,10 +1,11 @@ +// ignore_for_file: unused_element + import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_tts/flutter_tts.dart'; import 'package:learn/models/flower_model.dart'; import 'package:learn/utils/assets_path.dart'; - -import '../../utils/const_dimensions.dart'; +import 'flowers_test.dart'; class FlowerPage extends StatefulWidget { const FlowerPage({super.key}); @@ -82,6 +83,12 @@ class _FlowerPageState extends State { await flutterTts.setPitch(1.0); await flutterTts.speak(name); } + void _navigateToFlowersTestPage(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const FlowersTestPage()), + ); + } @override Widget build(BuildContext context) { @@ -95,6 +102,14 @@ class _FlowerPageState extends State { fontSize: 30, ), ), + actions: [ + IconButton( + icon: const Icon(Icons.assignment), + onPressed: () { + _navigateToFlowersTestPage(context); + }, + ), + ], ), backgroundColor: flower.background, body: SingleChildScrollView( @@ -119,7 +134,7 @@ class _FlowerPageState extends State { children: [ GestureDetector( onTap: _navigateToNextFlower, - child: Container( + child: SizedBox( width: double.infinity, height: 300, child: SvgPicture.asset( diff --git a/lib/pages/modules/flowers_test.dart b/lib/pages/modules/flowers_test.dart new file mode 100644 index 0000000..5281b92 --- /dev/null +++ b/lib/pages/modules/flowers_test.dart @@ -0,0 +1,216 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class FlowerQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + FlowerQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class FlowersTestPage extends StatefulWidget { + const FlowersTestPage({Key? key}) : super(key: key); + + @override + _FlowersTestPageState createState() => _FlowersTestPageState(); +} + +class _FlowersTestPageState extends State { + List questions = [ + FlowerQuestion( + imageAsset: 'assets/images/flowers/carnation.svg', + options: ['Carnation', 'Daffodil', 'Daisy', 'Hibiscus'], + correctAnswer: 'Carnation', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/daffodil.svg', + options: ['Lavender', 'Lily', 'Marigold', 'Daffodil'], + correctAnswer: 'Daffodil', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/daisy.svg', + options: ['Poppy', 'Tulip', 'Sunflower', 'Daisy'], + correctAnswer: 'Daisy', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/hibiscus.svg', + options: ['Carnation', 'Daffodil', 'Hibiscus', 'Lavender'], + correctAnswer: 'Hibiscus', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/lavender.svg', + options: ['Lily', 'Lavender', 'Marigold', 'Rose'], + correctAnswer: 'Lavender', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/lily.svg', + options: ['Lily', 'Carnation', 'Sunflower', 'Marigold'], + correctAnswer: 'Lily', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/marigold.svg', + options: ['Rose', 'Marigold', 'Daisy', 'Sunflower'], + correctAnswer: 'Marigold', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/rose.svg', + options: ['Tulip', 'Poppy', 'Rose', 'Hibiscus'], + correctAnswer: 'Rose', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/poppy.svg', + options: ['Poppy', 'Carnation', 'Sunflower', 'Daffodil'], + correctAnswer: 'Poppy', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/tulip.svg', + options: ['Lily', 'Tulip', 'Marigold', 'Sunflower'], + correctAnswer: 'Tulip', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/sunflower.svg', + options: ['Sunflower', 'Hibiscus', 'Lavender', 'Daisy'], + correctAnswer: 'Sunflower', + ), + ]; + + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + FlowerQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Flowers Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: +6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, // Random color + ), + child: Center( + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/occupation.dart b/lib/pages/modules/occupation.dart index 4225e71..daa9a6e 100644 --- a/lib/pages/modules/occupation.dart +++ b/lib/pages/modules/occupation.dart @@ -6,6 +6,7 @@ import 'package:learn/models/occupation_model.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; +import 'occupations_test.dart'; class OccupationPage extends StatelessWidget { final FlutterTts flutterTts = FlutterTts(); @@ -26,6 +27,17 @@ class OccupationPage extends StatelessWidget { Navigator.pop(context); }, ), + actions: [ + IconButton( + icon: const Icon(Icons.assessment), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const OccupationsTestPage()), + ); + }, + ), + ], ), body: SingleChildScrollView( child: Center( diff --git a/lib/pages/modules/occupations_test.dart b/lib/pages/modules/occupations_test.dart new file mode 100644 index 0000000..5cb1a68 --- /dev/null +++ b/lib/pages/modules/occupations_test.dart @@ -0,0 +1,226 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class OccupationQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + OccupationQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class OccupationsTestPage extends StatefulWidget { + const OccupationsTestPage({Key? key}) : super(key: key); + + @override + _OccupationsTestPageState createState() => _OccupationsTestPageState(); +} + +class _OccupationsTestPageState extends State { + List questions = [ + OccupationQuestion( + imageAsset: 'assets/images/occupations/artist.svg', + options: ['Artist', 'Author', 'Carpenter', 'Electrician'], + correctAnswer: 'Artist', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/author.svg', + options: ['Pilot', 'Police', 'Teacher', 'Author'], + correctAnswer: 'Author', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/carpenter.svg', + options: ['Farmer', 'Engineer', 'Carpenter', 'Vet'], + correctAnswer: 'Carpenter', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/electrician.svg', + options: ['Engineer', 'Electrician', 'Farmer', 'Teacher'], + correctAnswer: 'Electrician', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/engineer.svg', + options: ['Engineer', 'Pilot', 'Farmer', 'Lawyer'], + correctAnswer: 'Engineer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/farmer.svg', + options: ['Teacher', 'Vet', 'Farmer', 'Photographer'], + correctAnswer: 'Farmer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/pilot.svg', + options: ['Pilot', 'Lawyer', 'Photographer', 'Barber'], + correctAnswer: 'Pilot', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/police.svg', + options: ['Engineer', 'Pilot', 'Police', 'Barber'], + correctAnswer: 'Police', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/teacher.svg', + options: ['Teacher', 'Vet', 'Photographer', 'Author'], + correctAnswer: 'Teacher', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/vet.svg', + options: ['Engineer', 'Lawyer', 'Vet', 'Author'], + correctAnswer: 'Vet', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/photographer.svg', + options: ['Pilot', 'Photographer', 'Carpenter', 'Barber'], + correctAnswer: 'Photographer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/lawyer.svg', + options: ['Lawyer', 'Carpenter', 'Electrician', 'Farmer'], + correctAnswer: 'Lawyer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/barber.svg', + options: ['Teacher', 'Barber', 'Vet', 'Author'], + correctAnswer: 'Barber', + ), + ]; + + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + OccupationQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Occupations Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, // Random color + ), + child: Center( + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} + diff --git a/lib/pages/modules/parts.dart b/lib/pages/modules/parts.dart index 04715b2..f9ca972 100644 --- a/lib/pages/modules/parts.dart +++ b/lib/pages/modules/parts.dart @@ -1,3 +1,5 @@ +// ignore_for_file: unused_element + import 'package:flutter/material.dart'; import 'package:flutter_card_swiper/flutter_card_swiper.dart'; import 'package:flutter_svg/flutter_svg.dart'; @@ -8,6 +10,7 @@ import 'package:learn/utils/functions.dart'; import 'package:learn/utils/responsive_screen_provider.dart'; import '../../utils/const_dimensions.dart'; +import 'parts_test.dart'; void main() { runApp( @@ -57,6 +60,12 @@ class _PartsPagePageState extends State { controller.dispose(); super.dispose(); } + void _navigateToPartsTestPage(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const PartsTestPage()), + ); + } @override Widget build(BuildContext context) { @@ -66,6 +75,14 @@ class _PartsPagePageState extends State { AppConstants.parts, style: TextStyle(fontWeight: FontWeight.bold), ), + actions: [ + IconButton( + icon: const Icon(Icons.assignment), + onPressed: () { + _navigateToPartsTestPage(context); + }, + ), + ], ), body: SafeArea( child: Column( diff --git a/lib/pages/modules/parts_test.dart b/lib/pages/modules/parts_test.dart new file mode 100644 index 0000000..680fb76 --- /dev/null +++ b/lib/pages/modules/parts_test.dart @@ -0,0 +1,261 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class PartQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + PartQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class PartsTestPage extends StatefulWidget { + const PartsTestPage({Key? key}) : super(key: key); + + @override + _PartsTestPageState createState() => _PartsTestPageState(); +} + +class _PartsTestPageState extends State { + List questions = [ + PartQuestion( + imageAsset: 'assets/images/body/ankle.svg', + options: ['Ankle', 'Arm', 'Back', 'Belly'], + correctAnswer: 'Ankle', + ), + PartQuestion( + imageAsset: 'assets/images/body/arm.svg', + options: ['Arm', 'Ankle', 'Back', 'Belly'], + correctAnswer: 'Arm', + ), + PartQuestion( + imageAsset: 'assets/images/body/back.svg', + options: ['Back', 'Ankle', 'Arm', 'Belly'], + correctAnswer: 'Back', + ), + PartQuestion( + imageAsset: 'assets/images/body/belly.svg', + options: ['Belly', 'Ankle', 'Arm', 'Back'], + correctAnswer: 'Belly', + ), + PartQuestion( + imageAsset: 'assets/images/body/ear.svg', + options: ['Ear', 'Eye', 'Nose', 'Mouth'], + correctAnswer: 'Ear', + ), + PartQuestion( + imageAsset: 'assets/images/body/chest.svg', + options: ['Chest', 'Back', 'Stomach', 'Neck'], + correctAnswer: 'Chest', + ), + PartQuestion( + imageAsset: 'assets/images/body/chin.svg', + options: ['Chin', 'Jaw', 'Lips', 'Nose'], + correctAnswer: 'Chin', + ), + PartQuestion( + imageAsset: 'assets/images/body/eye.svg', + options: ['Eye', 'Ear', 'Nose', 'Mouth'], + correctAnswer: 'Eye', + ), + PartQuestion( + imageAsset: 'assets/images/body/fingers.svg', + options: ['Fingers', 'Toes', 'Hand', 'Feet'], + correctAnswer: 'Fingers', + ), + PartQuestion( + imageAsset: 'assets/images/body/foot.svg', + options: ['Foot', 'Hand', 'Fingers', 'Toes'], + correctAnswer: 'Foot', + ), + PartQuestion( + imageAsset: 'assets/images/body/lips.svg', + options: ['Lips', 'Nose', 'Chin', 'Teeth'], + correctAnswer: 'Lips', + ), + PartQuestion( + imageAsset: 'assets/images/body/knee.svg', + options: ['Knee', 'Ankle', 'Leg', 'Elbow'], + correctAnswer: 'Knee', + ), + PartQuestion( + imageAsset: 'assets/images/body/hips.svg', + options: ['Hips', 'Waist', 'Legs', 'Thighs'], + correctAnswer: 'Hips', + ), + PartQuestion( + imageAsset: 'assets/images/body/legs.svg', + options: ['Legs', 'Arms', 'Feet', 'Hands'], + correctAnswer: 'Legs', + ), + PartQuestion( + imageAsset: 'assets/images/body/stomach.svg', + options: ['Stomach', 'Chest', 'Back', 'Neck'], + correctAnswer: 'Stomach', + ), + PartQuestion( + imageAsset: 'assets/images/body/nose.svg', + options: ['Nose', 'Mouth', 'Ear', 'Eye'], + correctAnswer: 'Nose', + ), + PartQuestion( + imageAsset: 'assets/images/body/neck.svg', + options: ['Neck', 'Shoulder', 'Head', 'Chest'], + correctAnswer: 'Neck', + ), + PartQuestion( + imageAsset: 'assets/images/body/teeth.svg', + options: ['Teeth', 'Tongue', 'Lips', 'Mouth'], + correctAnswer: 'Teeth', + ), + PartQuestion( + imageAsset: 'assets/images/body/tongue.svg', + options: ['Tongue', 'Teeth', 'Lips', 'Mouth'], + correctAnswer: 'Tongue', + ), + PartQuestion( + imageAsset: 'assets/images/body/wrist.svg', + options: ['Wrist', 'Elbow', 'Arm', 'Hand'], + correctAnswer: 'Wrist', + ), + ]; + + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + PartQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Parts Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets +.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, // Random color + ), + child: Center( + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/pages/modules/planets.dart b/lib/pages/modules/planets.dart index 2ee6b88..066274e 100644 --- a/lib/pages/modules/planets.dart +++ b/lib/pages/modules/planets.dart @@ -7,6 +7,7 @@ import 'package:just_audio/just_audio.dart'; import 'package:learn/utils/assets_path.dart'; import '../../utils/const_dimensions.dart'; import 'package:learn/models/planet_model.dart'; +import 'planets_test.dart'; class PlanetsPage extends StatelessWidget { final List planets = [ @@ -70,7 +71,12 @@ class PlanetsPage extends StatelessWidget { final AudioPlayer audioPlayer = AudioPlayer(); PlanetsPage({Key? key}) : super(key: key); - + void _navigateToPlanetsTestPage(BuildContext context) { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const PlanetsTestPage()), + ); + } @override Widget build(BuildContext context) { return Scaffold( @@ -85,6 +91,14 @@ class PlanetsPage extends StatelessWidget { Navigator.pop(context); }, ), + actions: [ + IconButton( + icon: const Icon(Icons.assignment), + onPressed: () { + _navigateToPlanetsTestPage(context); + }, + ), + ], ), body: SingleChildScrollView( child: Center( diff --git a/lib/pages/modules/planets_test.dart b/lib/pages/modules/planets_test.dart new file mode 100644 index 0000000..da0f408 --- /dev/null +++ b/lib/pages/modules/planets_test.dart @@ -0,0 +1,206 @@ +// ignore_for_file: library_private_types_in_public_api + +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +class PlanetQuestion { + final String imageAsset; + final List options; + final String correctAnswer; + + PlanetQuestion({ + required this.imageAsset, + required this.options, + required this.correctAnswer, + }); +} + +class PlanetsTestPage extends StatefulWidget { + const PlanetsTestPage({Key? key}) : super(key: key); + + @override + _PlanetsTestPageState createState() => _PlanetsTestPageState(); +} + +class _PlanetsTestPageState extends State { + List questions = [ + PlanetQuestion( + imageAsset: 'assets/images/solar/earth.svg', + options: ['Earth', 'Mars', 'Jupiter', 'Neptune'], + correctAnswer: 'Earth', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/mars.svg', + options: ['Mercury', 'Mars', 'Saturn', 'Jupiter'], + correctAnswer: 'Mars', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/jupiter.svg', + options: ['Saturn', 'Jupiter', 'Uranus', 'Neptune'], + correctAnswer: 'Jupiter', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/neptune.svg', + options: ['Neptune', 'Mercury', 'Venus', 'Uranus'], + correctAnswer: 'Neptune', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/mercury.svg', + options: ['Venus', 'Mercury', 'Sun', 'Earth'], + correctAnswer: 'Mercury', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/saturn.svg', + options: ['Jupiter', 'Mars', 'Saturn', 'Sun'], + correctAnswer: 'Saturn', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/sun.svg', + options: ['Venus', 'Sun', 'Earth', 'Mercury'], + correctAnswer: 'Sun', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/venus.svg', + options: ['Mars', 'Venus', 'Uranus', 'Neptune'], + correctAnswer: 'Venus', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/uranus.svg', + options: ['Saturn', 'Jupiter', 'Neptune', 'Uranus'], + correctAnswer: 'Uranus', + ), + ]; + + int currentQuestionIndex = 0; + int correctAnswers = 0; + bool showFeedback = false; + bool isCorrect = false; + + void _checkAnswer(String answer) { + setState(() { + isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + if (isCorrect) { + correctAnswers++; + } + showFeedback = true; + }); + } + + void _nextQuestion() { + setState(() { + if (currentQuestionIndex < questions.length - 1) { + currentQuestionIndex++; + showFeedback = false; + } else { + showFeedback = false; + _showFinalScore(context); + } + }); + } + + void _restartQuiz() { + setState(() { + currentQuestionIndex = 0; + correctAnswers = 0; + showFeedback = false; + }); + } + + void _showFinalScore(BuildContext context) { + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Quiz Completed'), + content: Text( + 'You got $correctAnswers out of ${questions.length} correct!', + style: const TextStyle(fontSize: 20), + ), + actions: [ + TextButton( + child: const Text('Restart'), + onPressed: () { + Navigator.of(context).pop(); + _restartQuiz(); + }, + ), + TextButton( + child: const Text('Close'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); + } + + @override + Widget build(BuildContext context) { + PlanetQuestion currentQuestion = questions[currentQuestionIndex]; + + return Scaffold( + appBar: AppBar( + title: const Text('Planets Test'), + ), + body: Center( + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Container( + width: 200, + height: 200, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(10), + color: Colors.amberAccent, + ), + child: SvgPicture.asset( + currentQuestion.imageAsset, + ), + ), + const SizedBox(height: 20), + ...currentQuestion.options.map((option) { + return Padding( + padding: const EdgeInsets.symmetric(vertical: +6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, // Random color + ), + child: Center( + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Text(option, style: const TextStyle(fontSize: 18)), + ), + ), + ), + ); + }).toList(), + if (showFeedback) + Text( + isCorrect ? 'Correct!' : 'Wrong!', + style: TextStyle( + color: isCorrect ? Colors.green : Colors.red, + fontSize: 24, + ), + ), + if (showFeedback) + ElevatedButton( + onPressed: _nextQuestion, + child: const Text('Next'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/utils/const_dimensions.dart b/lib/utils/const_dimensions.dart index bb30064..459d8cc 100644 --- a/lib/utils/const_dimensions.dart +++ b/lib/utils/const_dimensions.dart @@ -1,3 +1,5 @@ +// ignore_for_file: constant_identifier_names + class ConstantDimensions { static const double heightExtraSmall = 6; static const double heightSmall = 10; diff --git a/lib/utils/route/routes.dart b/lib/utils/route/routes.dart index e6c8de0..311f1f5 100644 --- a/lib/utils/route/routes.dart +++ b/lib/utils/route/routes.dart @@ -58,7 +58,7 @@ class Routers { case AllRoutesConstant.landing: return slidePageRoute(const LandingPage()); case AllRoutesConstant.mainhome: - return slidePageRoute(MainHome()); + return slidePageRoute(const MainHome()); default: return MaterialPageRoute( builder: (context) => const Scaffold( From 9ed8b548a075f07d186636858efc77428793b3b3 Mon Sep 17 00:00:00 2001 From: NamrataCSalvi <147251955+NamrataCSalvi@users.noreply.github.com> Date: Sun, 2 Jun 2024 13:04:59 +0530 Subject: [PATCH 2/9] Fixed the issues on quizes fixed the issues in body parts and birds quiz as well as made the whole box clickable --- lib/pages/modules/animals_test.dart | 64 ++++--- lib/pages/modules/birds_test.dart | 214 +++++++++++++----------- lib/pages/modules/flowers_test.dart | 73 ++++---- lib/pages/modules/occupations_test.dart | 165 ++++++++++-------- lib/pages/modules/parts_test.dart | 99 ++++++----- lib/pages/modules/planets_test.dart | 67 ++++---- 6 files changed, 380 insertions(+), 302 deletions(-) diff --git a/lib/pages/modules/animals_test.dart b/lib/pages/modules/animals_test.dart index bbf37ad..161cd6e 100644 --- a/lib/pages/modules/animals_test.dart +++ b/lib/pages/modules/animals_test.dart @@ -23,7 +23,7 @@ class AnimalsTestPage extends StatefulWidget { } class _AnimalsTestPageState extends State { - List questions = [ + List allQuestions = [ AnimalQuestion( imageAsset: 'assets/images/animal/lion.svg', options: ['Lion', 'Tiger', 'Leopard', 'Cheetah'], @@ -34,21 +34,11 @@ class _AnimalsTestPageState extends State { options: ['Rhino', 'Hippo', 'Elephant', 'Giraffe'], correctAnswer: 'Elephant', ), - AnimalQuestion( - imageAsset: 'assets/images/animal/bear.svg', - options: ['Wolf', 'Fox', 'Bear', 'Dog'], - correctAnswer: 'Bear', - ), AnimalQuestion( imageAsset: 'assets/images/animal/cat.svg', options: ['Dog', 'Cat', 'Rabbit', 'Squirrel'], correctAnswer: 'Cat', ), - AnimalQuestion( - imageAsset: 'assets/images/animal/cow.svg', - options: ['Goat', 'Sheep', 'Buffalo', 'Cow'], - correctAnswer: 'Cow', - ), AnimalQuestion( imageAsset: 'assets/images/animal/deer.svg', options: ['Deer', 'Moose', 'Antelope', 'Elk'], @@ -84,13 +74,34 @@ class _AnimalsTestPageState extends State { options: ['Hare', 'Squirrel', 'Guinea Pig', 'Rabbit'], correctAnswer: 'Rabbit', ), + AnimalQuestion( + imageAsset: 'assets/images/animal/bear.svg', + options: ['Wolf', 'Fox', 'Bear', 'Dog'], + correctAnswer: 'Bear', + ), + AnimalQuestion( + imageAsset: 'assets/images/animal/cow.svg', + options: ['Goat', 'Sheep', 'Buffalo', 'Cow'], + correctAnswer: 'Cow', + ), ]; + List questions = []; int currentQuestionIndex = 0; int correctAnswers = 0; bool showFeedback = false; bool isCorrect = false; + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + void _checkAnswer(String answer) { setState(() { isCorrect = questions[currentQuestionIndex].correctAnswer == answer; @@ -118,6 +129,7 @@ class _AnimalsTestPageState extends State { currentQuestionIndex = 0; correctAnswers = 0; showFeedback = false; + _shuffleQuestions(); }); } @@ -171,7 +183,7 @@ class _AnimalsTestPageState extends State { decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10), - color: Colors.amberAccent, + color: Colors.amberAccent, ), child: SvgPicture.asset( currentQuestion.imageAsset, @@ -179,23 +191,23 @@ class _AnimalsTestPageState extends State { ), const SizedBox(height: 20), ...currentQuestion.options.map((option) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 6.0), - child: Container( - width: 200, - height: 40, - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(1), - color: Colors.lightBlueAccent, // Random color - ), - child: Center( - child: GestureDetector( - onTap: () => _checkAnswer(option), + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( child: Text(option, style: const TextStyle(fontSize: 18)), + ), ), ), - ), ); }).toList(), if (showFeedback) diff --git a/lib/pages/modules/birds_test.dart b/lib/pages/modules/birds_test.dart index ba84e77..5208242 100644 --- a/lib/pages/modules/birds_test.dart +++ b/lib/pages/modules/birds_test.dart @@ -19,99 +19,109 @@ class BirdsTestPage extends StatefulWidget { const BirdsTestPage({Key? key}) : super(key: key); @override - _AnimalsTestPageState createState() => _AnimalsTestPageState(); + _BirdsTestPageState createState() => _BirdsTestPageState(); } -class _AnimalsTestPageState extends State { - List questions = [ - BirdQuestion( - imageAsset: 'assets/images/birds/bagula.svg', - options: ['Bagula', 'Bulbul', 'Crow', 'Duck'], - correctAnswer: 'Bagula', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/bulbul.svg', - options: ['Eagle', 'Goose', 'Bulbul', 'Hen'], - correctAnswer: 'Bulbul', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/crow.svg', - options: ['Koel', 'Maina', 'Crow', 'Ostrich'], - correctAnswer: 'Crow', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/duck.svg', - options: ['Owl', 'Parrot', 'Pigeon', 'Duck'], - correctAnswer: 'Duck', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/eagle.svg', - options: ['Eagle', 'Sparrow', 'Swan', 'Vulture'], - correctAnswer: 'Eagle', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/goose.svg', - options: ['Crow', 'Goose', 'Hen', 'Koel'], - correctAnswer: 'Goose', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/hen.svg', - options: ['Maina', 'Ostrich', 'Hen', 'Parrot'], - correctAnswer: 'Hen', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/koel.svg', - options: ['Pigeon', 'Koel', 'Sparrow', 'Swan'], - correctAnswer: 'Koel', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/maina.svg', - options: ['Vulture', 'Maina', 'Eagle', 'Goose'], - correctAnswer: 'Maina', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/ostrich.svg', - options: ['Duck', 'Ostrich', 'Owl', 'Parrot'], - correctAnswer: 'Ostrich', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/owl.svg', - options: ['Pigeon', 'Owl', 'Sparrow', 'Swan'], - correctAnswer: 'Owl', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/parrot.svg', - options: ['Vulture', 'Bagula', 'Parrot', 'Bulbul'], - correctAnswer: 'Parrot', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/pigeon.svg', - options: ['Crow', 'Duck', 'Pigeon', 'Eagle'], - correctAnswer: 'Pigeon', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/sparrow.svg', - options: ['Goose', 'Hen', 'Sparrow', 'Koel'], - correctAnswer: 'Sparrow', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/swan.svg', - options: ['Maina', 'Ostrich', 'Swan', 'Owl'], - correctAnswer: 'Swan', - ), - BirdQuestion( - imageAsset: 'assets/images/birds/vulture.svg', - options: ['Parrot', 'Pigeon', 'Vulture', 'Sparrow'], - correctAnswer: 'Vulture', - ), -]; - +class _BirdsTestPageState extends State { + List allQuestions = [ + BirdQuestion( + imageAsset: 'assets/images/birds/duck.svg', + options: ['Owl', 'Parrot', 'Pigeon', 'Duck'], + correctAnswer: 'Duck', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/hen.svg', + options: ['Maina', 'Ostrich', 'Hen', 'Parrot'], + correctAnswer: 'Hen', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/maina.svg', + options: ['Vulture', 'Maina', 'Eagle', 'Goose'], + correctAnswer: 'Maina', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/pigeon.svg', + options: ['Crow', 'Duck', 'Pigeon', 'Eagle'], + correctAnswer: 'Pigeon', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/sparrow.svg', + options: ['Goose', 'Hen', 'Sparrow', 'Koel'], + correctAnswer: 'Sparrow', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/bagula.svg', + options: ['Bagula', 'Bulbul', 'Crow', 'Duck'], + correctAnswer: 'Bagula', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/bulbul.svg', + options: ['Eagle', 'Goose', 'Bulbul', 'Hen'], + correctAnswer: 'Bulbul', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/crow.svg', + options: ['Koel', 'Maina', 'Crow', 'Ostrich'], + correctAnswer: 'Crow', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/eagle.svg', + options: ['Eagle', 'Sparrow', 'Swan', 'Vulture'], + correctAnswer: 'Eagle', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/goose.svg', + options: ['Crow', 'Goose', 'Hen', 'Koel'], + correctAnswer: 'Goose', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/koel.svg', + options: ['Pigeon', 'Koel', 'Sparrow', 'Swan'], + correctAnswer: 'Koel', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/ostrich.svg', + options: ['Duck', 'Ostrich', 'Owl', 'Parrot'], + correctAnswer: 'Ostrich', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/owl.svg', + options: ['Pigeon', 'Owl', 'Sparrow', 'Swan'], + correctAnswer: 'Owl', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/parrot.svg', + options: ['Vulture', 'Bagula', 'Parrot', 'Bulbul'], + correctAnswer: 'Parrot', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/swan.svg', + options: ['Maina', 'Ostrich', 'Swan', 'Owl'], + correctAnswer: 'Swan', + ), + BirdQuestion( + imageAsset: 'assets/images/birds/vulture.svg', + options: ['Parrot', 'Pigeon', 'Vulture', 'Sparrow'], + correctAnswer: 'Vulture', + ), + ]; + List questions = []; int currentQuestionIndex = 0; int correctAnswers = 0; bool showFeedback = false; bool isCorrect = false; + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + void _checkAnswer(String answer) { setState(() { isCorrect = questions[currentQuestionIndex].correctAnswer == answer; @@ -139,6 +149,7 @@ class _AnimalsTestPageState extends State { currentQuestionIndex = 0; correctAnswers = 0; showFeedback = false; + _shuffleQuestions(); }); } @@ -178,7 +189,7 @@ class _AnimalsTestPageState extends State { return Scaffold( appBar: AppBar( - title: const Text('Animals Test'), + title: const Text('Birds Test'), ), body: Center( child: Padding( @@ -192,7 +203,7 @@ class _AnimalsTestPageState extends State { decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10), - color: Colors.amberAccent, + color: Colors.amberAccent, ), child: SvgPicture.asset( currentQuestion.imageAsset, @@ -200,23 +211,24 @@ class _AnimalsTestPageState extends State { ), const SizedBox(height: 20), ...currentQuestion.options.map((option) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: 6.0), - child: Container( - width: 200, - height: 40, - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(1), - color: Colors.lightBlueAccent, // Random color - ), - child: Center( - child: GestureDetector( - onTap: () => _checkAnswer(option), + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( child: Text(option, style: const TextStyle(fontSize: 18)), + ), ), ), - ), ); }).toList(), if (showFeedback) diff --git a/lib/pages/modules/flowers_test.dart b/lib/pages/modules/flowers_test.dart index 5281b92..764b7bb 100644 --- a/lib/pages/modules/flowers_test.dart +++ b/lib/pages/modules/flowers_test.dart @@ -23,7 +23,7 @@ class FlowersTestPage extends StatefulWidget { } class _FlowersTestPageState extends State { - List questions = [ + List allQuestions = [ FlowerQuestion( imageAsset: 'assets/images/flowers/carnation.svg', options: ['Carnation', 'Daffodil', 'Daisy', 'Hibiscus'], @@ -34,6 +34,21 @@ class _FlowersTestPageState extends State { options: ['Lavender', 'Lily', 'Marigold', 'Daffodil'], correctAnswer: 'Daffodil', ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/lily.svg', + options: ['Lily', 'Carnation', 'Sunflower', 'Marigold'], + correctAnswer: 'Lily', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/rose.svg', + options: ['Tulip', 'Poppy', 'Rose', 'Hibiscus'], + correctAnswer: 'Rose', + ), + FlowerQuestion( + imageAsset: 'assets/images/flowers/sunflower.svg', + options: ['Sunflower', 'Hibiscus', 'Lavender', 'Daisy'], + correctAnswer: 'Sunflower', + ), FlowerQuestion( imageAsset: 'assets/images/flowers/daisy.svg', options: ['Poppy', 'Tulip', 'Sunflower', 'Daisy'], @@ -49,21 +64,11 @@ class _FlowersTestPageState extends State { options: ['Lily', 'Lavender', 'Marigold', 'Rose'], correctAnswer: 'Lavender', ), - FlowerQuestion( - imageAsset: 'assets/images/flowers/lily.svg', - options: ['Lily', 'Carnation', 'Sunflower', 'Marigold'], - correctAnswer: 'Lily', - ), FlowerQuestion( imageAsset: 'assets/images/flowers/marigold.svg', options: ['Rose', 'Marigold', 'Daisy', 'Sunflower'], correctAnswer: 'Marigold', ), - FlowerQuestion( - imageAsset: 'assets/images/flowers/rose.svg', - options: ['Tulip', 'Poppy', 'Rose', 'Hibiscus'], - correctAnswer: 'Rose', - ), FlowerQuestion( imageAsset: 'assets/images/flowers/poppy.svg', options: ['Poppy', 'Carnation', 'Sunflower', 'Daffodil'], @@ -74,18 +79,24 @@ class _FlowersTestPageState extends State { options: ['Lily', 'Tulip', 'Marigold', 'Sunflower'], correctAnswer: 'Tulip', ), - FlowerQuestion( - imageAsset: 'assets/images/flowers/sunflower.svg', - options: ['Sunflower', 'Hibiscus', 'Lavender', 'Daisy'], - correctAnswer: 'Sunflower', - ), ]; + List questions = []; int currentQuestionIndex = 0; int correctAnswers = 0; bool showFeedback = false; bool isCorrect = false; + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + void _checkAnswer(String answer) { setState(() { isCorrect = questions[currentQuestionIndex].correctAnswer == answer; @@ -113,6 +124,7 @@ class _FlowersTestPageState extends State { currentQuestionIndex = 0; correctAnswers = 0; showFeedback = false; + _shuffleQuestions(); }); } @@ -166,7 +178,7 @@ class _FlowersTestPageState extends State { decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10), - color: Colors.amberAccent, + color: Colors.amberAccent, ), child: SvgPicture.asset( currentQuestion.imageAsset, @@ -174,20 +186,19 @@ class _FlowersTestPageState extends State { ), const SizedBox(height: 20), ...currentQuestion.options.map((option) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: -6.0), - child: Container( - width: 200, - height: 40, - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(1), - color: Colors.lightBlueAccent, // Random color - ), - child: Center( - child: GestureDetector( - onTap: () => _checkAnswer(option), + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( child: Text(option, style: const TextStyle(fontSize: 18)), ), ), diff --git a/lib/pages/modules/occupations_test.dart b/lib/pages/modules/occupations_test.dart index 5cb1a68..04a1b41 100644 --- a/lib/pages/modules/occupations_test.dart +++ b/lib/pages/modules/occupations_test.dart @@ -23,58 +23,61 @@ class OccupationsTestPage extends StatefulWidget { } class _OccupationsTestPageState extends State { - List questions = [ - OccupationQuestion( - imageAsset: 'assets/images/occupations/artist.svg', - options: ['Artist', 'Author', 'Carpenter', 'Electrician'], - correctAnswer: 'Artist', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/author.svg', - options: ['Pilot', 'Police', 'Teacher', 'Author'], - correctAnswer: 'Author', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/carpenter.svg', - options: ['Farmer', 'Engineer', 'Carpenter', 'Vet'], - correctAnswer: 'Carpenter', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/electrician.svg', - options: ['Engineer', 'Electrician', 'Farmer', 'Teacher'], - correctAnswer: 'Electrician', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/engineer.svg', - options: ['Engineer', 'Pilot', 'Farmer', 'Lawyer'], - correctAnswer: 'Engineer', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/farmer.svg', - options: ['Teacher', 'Vet', 'Farmer', 'Photographer'], - correctAnswer: 'Farmer', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/pilot.svg', - options: ['Pilot', 'Lawyer', 'Photographer', 'Barber'], - correctAnswer: 'Pilot', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/police.svg', - options: ['Engineer', 'Pilot', 'Police', 'Barber'], - correctAnswer: 'Police', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/teacher.svg', - options: ['Teacher', 'Vet', 'Photographer', 'Author'], - correctAnswer: 'Teacher', - ), - OccupationQuestion( - imageAsset: 'assets/images/occupations/vet.svg', - options: ['Engineer', 'Lawyer', 'Vet', 'Author'], - correctAnswer: 'Vet', - ), - OccupationQuestion( + List> questionSets = [ + [ + OccupationQuestion( + imageAsset: 'assets/images/occupations/artist.svg', + options: ['Artist', 'Author', 'Carpenter', 'Electrician'], + correctAnswer: 'Artist', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/engineer.svg', + options: ['Engineer', 'Pilot', 'Farmer', 'Lawyer'], + correctAnswer: 'Engineer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/farmer.svg', + options: ['Teacher', 'Vet', 'Farmer', 'Photographer'], + correctAnswer: 'Farmer', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/police.svg', + options: ['Engineer', 'Pilot', 'Police', 'Barber'], + correctAnswer: 'Police', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/teacher.svg', + options: ['Teacher', 'Vet', 'Photographer', 'Author'], + correctAnswer: 'Teacher', + ), + ], + [ + OccupationQuestion( + imageAsset: 'assets/images/occupations/author.svg', + options: ['Pilot', 'Police', 'Teacher', 'Author'], + correctAnswer: 'Author', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/carpenter.svg', + options: ['Farmer', 'Engineer', 'Carpenter', 'Vet'], + correctAnswer: 'Carpenter', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/electrician.svg', + options: ['Engineer', 'Electrician', 'Farmer', 'Teacher'], + correctAnswer: 'Electrician', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/vet.svg', + options: ['Engineer', 'Lawyer', 'Vet', 'Author'], + correctAnswer: 'Vet', + ), + OccupationQuestion( + imageAsset: 'assets/images/occupations/photographer.svg', + options: ['Pilot', 'Photographer', 'Carpenter', 'Barber'], + correctAnswer: 'Photographer', + ), + OccupationQuestion( imageAsset: 'assets/images/occupations/photographer.svg', options: ['Pilot', 'Photographer', 'Carpenter', 'Barber'], correctAnswer: 'Photographer', @@ -89,16 +92,31 @@ class _OccupationsTestPageState extends State { options: ['Teacher', 'Barber', 'Vet', 'Author'], correctAnswer: 'Barber', ), + ], + ]; + int currentQuestionSetIndex = 0; int currentQuestionIndex = 0; int correctAnswers = 0; bool showFeedback = false; bool isCorrect = false; + @override + void initState() { + super.initState(); + _shuffleQuestions(); + } + + void _shuffleQuestions() { + for (var questionSet in questionSets) { + questionSet.shuffle(); + } + } + void _checkAnswer(String answer) { setState(() { - isCorrect = questions[currentQuestionIndex].correctAnswer == answer; + isCorrect = questionSets[currentQuestionSetIndex][currentQuestionIndex].correctAnswer == answer; if (isCorrect) { correctAnswers++; } @@ -108,21 +126,28 @@ class _OccupationsTestPageState extends State { void _nextQuestion() { setState(() { - if (currentQuestionIndex < questions.length - 1) { + if (currentQuestionIndex < questionSets[currentQuestionSetIndex].length - 1) { currentQuestionIndex++; showFeedback = false; } else { - showFeedback = false; - _showFinalScore(context); + if (currentQuestionSetIndex < questionSets.length - 1) { + currentQuestionSetIndex++; + currentQuestionIndex = 0; + } else { + showFeedback = false; + _showFinalScore(context); + return; + } } }); } void _restartQuiz() { setState(() { + currentQuestionSetIndex = 0; currentQuestionIndex = 0; correctAnswers = 0; - showFeedback = false; + _shuffleQuestions(); }); } @@ -133,7 +158,7 @@ class _OccupationsTestPageState extends State { return AlertDialog( title: const Text('Quiz Completed'), content: Text( - 'You got $correctAnswers out of ${questions.length} correct!', + 'You got $correctAnswers out of ${questionSets[currentQuestionSetIndex].length} correct!', style: const TextStyle(fontSize: 20), ), actions: [ @@ -158,7 +183,7 @@ class _OccupationsTestPageState extends State { @override Widget build(BuildContext context) { - OccupationQuestion currentQuestion = questions[currentQuestionIndex]; + OccupationQuestion currentQuestion = questionSets[currentQuestionSetIndex][currentQuestionIndex]; return Scaffold( appBar: AppBar( @@ -186,17 +211,17 @@ class _OccupationsTestPageState extends State { ...currentQuestion.options.map((option) { return Padding( padding: const EdgeInsets.symmetric(vertical: 6.0), - child: Container( - width: 200, - height: 40, - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(1), - color: Colors.lightBlueAccent, // Random color - ), - child: Center( - child: GestureDetector( - onTap: () => _checkAnswer(option), + child: GestureDetector( + onTap: () => _checkAnswer(option), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( child: Text(option, style: const TextStyle(fontSize: 18)), ), ), diff --git a/lib/pages/modules/parts_test.dart b/lib/pages/modules/parts_test.dart index 680fb76..9b734be 100644 --- a/lib/pages/modules/parts_test.dart +++ b/lib/pages/modules/parts_test.dart @@ -23,17 +23,38 @@ class PartsTestPage extends StatefulWidget { } class _PartsTestPageState extends State { - List questions = [ + List allQuestions = [ + // Define all PartQuestion objects here + PartQuestion( + imageAsset: 'assets/images/body/arm.svg', + options: ['Ankle', 'Back', 'Arm', 'Belly'], + correctAnswer: 'Arm', + ), + PartQuestion( + imageAsset: 'assets/images/body/eye.svg', + options: ['Ear', 'Eye', 'Nose', 'Mouth'], + correctAnswer: 'Eye', + ), + PartQuestion( + imageAsset: 'assets/images/body/foot.svg', + options: ['Hand', 'Fingers', 'Toes', 'Foot'], + correctAnswer: 'Foot', + ), + PartQuestion( + imageAsset: 'assets/images/body/nose.svg', + options: ['Nose', 'Mouth', 'Ear', 'Eye'], + correctAnswer: 'Nose', + ), + PartQuestion( + imageAsset: 'assets/images/body/tongue.svg', + options: ['Teeth', 'Lips', 'Tongue', 'Mouth'], + correctAnswer: 'Tongue', + ), PartQuestion( imageAsset: 'assets/images/body/ankle.svg', options: ['Ankle', 'Arm', 'Back', 'Belly'], correctAnswer: 'Ankle', ), - PartQuestion( - imageAsset: 'assets/images/body/arm.svg', - options: ['Arm', 'Ankle', 'Back', 'Belly'], - correctAnswer: 'Arm', - ), PartQuestion( imageAsset: 'assets/images/body/back.svg', options: ['Back', 'Ankle', 'Arm', 'Belly'], @@ -59,21 +80,11 @@ class _PartsTestPageState extends State { options: ['Chin', 'Jaw', 'Lips', 'Nose'], correctAnswer: 'Chin', ), - PartQuestion( - imageAsset: 'assets/images/body/eye.svg', - options: ['Eye', 'Ear', 'Nose', 'Mouth'], - correctAnswer: 'Eye', - ), PartQuestion( imageAsset: 'assets/images/body/fingers.svg', options: ['Fingers', 'Toes', 'Hand', 'Feet'], correctAnswer: 'Fingers', ), - PartQuestion( - imageAsset: 'assets/images/body/foot.svg', - options: ['Foot', 'Hand', 'Fingers', 'Toes'], - correctAnswer: 'Foot', - ), PartQuestion( imageAsset: 'assets/images/body/lips.svg', options: ['Lips', 'Nose', 'Chin', 'Teeth'], @@ -89,21 +100,11 @@ class _PartsTestPageState extends State { options: ['Hips', 'Waist', 'Legs', 'Thighs'], correctAnswer: 'Hips', ), - PartQuestion( - imageAsset: 'assets/images/body/legs.svg', - options: ['Legs', 'Arms', 'Feet', 'Hands'], - correctAnswer: 'Legs', - ), PartQuestion( imageAsset: 'assets/images/body/stomach.svg', options: ['Stomach', 'Chest', 'Back', 'Neck'], correctAnswer: 'Stomach', ), - PartQuestion( - imageAsset: 'assets/images/body/nose.svg', - options: ['Nose', 'Mouth', 'Ear', 'Eye'], - correctAnswer: 'Nose', - ), PartQuestion( imageAsset: 'assets/images/body/neck.svg', options: ['Neck', 'Shoulder', 'Head', 'Chest'], @@ -114,11 +115,6 @@ class _PartsTestPageState extends State { options: ['Teeth', 'Tongue', 'Lips', 'Mouth'], correctAnswer: 'Teeth', ), - PartQuestion( - imageAsset: 'assets/images/body/tongue.svg', - options: ['Tongue', 'Teeth', 'Lips', 'Mouth'], - correctAnswer: 'Tongue', - ), PartQuestion( imageAsset: 'assets/images/body/wrist.svg', options: ['Wrist', 'Elbow', 'Arm', 'Hand'], @@ -126,11 +122,22 @@ class _PartsTestPageState extends State { ), ]; + List questions = []; int currentQuestionIndex = 0; int correctAnswers = 0; bool showFeedback = false; bool isCorrect = false; + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + void _checkAnswer(String answer) { setState(() { isCorrect = questions[currentQuestionIndex].correctAnswer == answer; @@ -158,6 +165,7 @@ class _PartsTestPageState extends State { currentQuestionIndex = 0; correctAnswers = 0; showFeedback = false; + _shuffleQuestions(); }); } @@ -211,7 +219,7 @@ class _PartsTestPageState extends State { decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10), - color: Colors.amberAccent, + color: Colors.amberAccent, ), child: SvgPicture.asset( currentQuestion.imageAsset, @@ -219,20 +227,19 @@ class _PartsTestPageState extends State { ), const SizedBox(height: 20), ...currentQuestion.options.map((option) { - return Padding( - padding: const EdgeInsets -.symmetric(vertical: 6.0), - child: Container( - width: 200, - height: 40, - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(1), - color: Colors.lightBlueAccent, // Random color - ), - child: Center( - child: GestureDetector( - onTap: () => _checkAnswer(option), + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( child: Text(option, style: const TextStyle(fontSize: 18)), ), ), diff --git a/lib/pages/modules/planets_test.dart b/lib/pages/modules/planets_test.dart index da0f408..7e1b1cf 100644 --- a/lib/pages/modules/planets_test.dart +++ b/lib/pages/modules/planets_test.dart @@ -23,7 +23,7 @@ class PlanetsTestPage extends StatefulWidget { } class _PlanetsTestPageState extends State { - List questions = [ + List allQuestions = [ PlanetQuestion( imageAsset: 'assets/images/solar/earth.svg', options: ['Earth', 'Mars', 'Jupiter', 'Neptune'], @@ -36,7 +36,7 @@ class _PlanetsTestPageState extends State { ), PlanetQuestion( imageAsset: 'assets/images/solar/jupiter.svg', - options: ['Saturn', 'Jupiter', 'Uranus', 'Neptune'], + options: ['Saturn', 'Uranus', 'Jupiter', 'Neptune'], correctAnswer: 'Jupiter', ), PlanetQuestion( @@ -44,19 +44,9 @@ class _PlanetsTestPageState extends State { options: ['Neptune', 'Mercury', 'Venus', 'Uranus'], correctAnswer: 'Neptune', ), - PlanetQuestion( - imageAsset: 'assets/images/solar/mercury.svg', - options: ['Venus', 'Mercury', 'Sun', 'Earth'], - correctAnswer: 'Mercury', - ), - PlanetQuestion( - imageAsset: 'assets/images/solar/saturn.svg', - options: ['Jupiter', 'Mars', 'Saturn', 'Sun'], - correctAnswer: 'Saturn', - ), PlanetQuestion( imageAsset: 'assets/images/solar/sun.svg', - options: ['Venus', 'Sun', 'Earth', 'Mercury'], + options: ['Venus', 'Earth', 'Mercury', 'Sun'], correctAnswer: 'Sun', ), PlanetQuestion( @@ -69,13 +59,34 @@ class _PlanetsTestPageState extends State { options: ['Saturn', 'Jupiter', 'Neptune', 'Uranus'], correctAnswer: 'Uranus', ), + PlanetQuestion( + imageAsset: 'assets/images/solar/mercury.svg', + options: ['Venus', 'Mercury', 'Sun', 'Earth'], + correctAnswer: 'Mercury', + ), + PlanetQuestion( + imageAsset: 'assets/images/solar/saturn.svg', + options: ['Jupiter', 'Mars', 'Saturn', 'Sun'], + correctAnswer: 'Saturn', + ), ]; + List questions = []; int currentQuestionIndex = 0; int correctAnswers = 0; bool showFeedback = false; bool isCorrect = false; + @override + void initState() { + super.initState(); + _restartQuiz(); + } + + void _shuffleQuestions() { + questions = (List.from(allQuestions)..shuffle()).take(5).toList(); + } + void _checkAnswer(String answer) { setState(() { isCorrect = questions[currentQuestionIndex].correctAnswer == answer; @@ -103,6 +114,7 @@ class _PlanetsTestPageState extends State { currentQuestionIndex = 0; correctAnswers = 0; showFeedback = false; + _shuffleQuestions(); }); } @@ -156,7 +168,7 @@ class _PlanetsTestPageState extends State { decoration: BoxDecoration( border: Border.all(color: Colors.black), borderRadius: BorderRadius.circular(10), - color: Colors.amberAccent, + color: Colors.amberAccent, ), child: SvgPicture.asset( currentQuestion.imageAsset, @@ -164,20 +176,19 @@ class _PlanetsTestPageState extends State { ), const SizedBox(height: 20), ...currentQuestion.options.map((option) { - return Padding( - padding: const EdgeInsets.symmetric(vertical: -6.0), - child: Container( - width: 200, - height: 40, - decoration: BoxDecoration( - border: Border.all(color: Colors.black), - borderRadius: BorderRadius.circular(1), - color: Colors.lightBlueAccent, // Random color - ), - child: Center( - child: GestureDetector( - onTap: () => _checkAnswer(option), + return GestureDetector( + onTap: () => _checkAnswer(option), + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 6.0), + child: Container( + width: 200, + height: 40, + decoration: BoxDecoration( + border: Border.all(color: Colors.black), + borderRadius: BorderRadius.circular(1), + color: Colors.lightBlueAccent, + ), + child: Center( child: Text(option, style: const TextStyle(fontSize: 18)), ), ), From 05823cbae1cd7246fb518b88233de7346862e7d0 Mon Sep 17 00:00:00 2001 From: NamrataCSalvi <147251955+NamrataCSalvi@users.noreply.github.com> Date: Sun, 2 Jun 2024 18:39:22 +0530 Subject: [PATCH 3/9] updated code for flowers.dart file --- lib/pages/fruits.dart | 4 ++ lib/pages/modules/atoz.dart | 7 +-- lib/pages/modules/flowers.dart | 84 ++++++++++++++++++++-------------- lib/pages/modules/seasons.dart | 3 +- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/lib/pages/fruits.dart b/lib/pages/fruits.dart index 78ca834..ad604fd 100644 --- a/lib/pages/fruits.dart +++ b/lib/pages/fruits.dart @@ -175,3 +175,7 @@ class _FruitsPageState extends State { bgColorInit(); } } + +class WidgetStateProperty { + static all(Size size) {} +} diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index 1236de5..a843f65 100644 --- a/lib/pages/modules/atoz.dart +++ b/lib/pages/modules/atoz.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'dart:async'; import 'package:flutter_tts/flutter_tts.dart'; +import 'package:learn/pages/fruits.dart'; import 'package:learn/utils/const_dimensions.dart'; import 'package:learn/models/itemdata_model.dart'; import 'package:learn/utils/constants.dart'; @@ -220,7 +221,7 @@ class _PopupDialogState extends State<_PopupDialog> { ElevatedButton( style: ButtonStyle( backgroundColor: WidgetStateProperty.all( - const Color.fromARGB(216, 233, 101, 92), + const Color.fromARGB(216, 233, 101, 92) as Size, ), ), onPressed: () { @@ -270,8 +271,8 @@ class _AtoZState extends State { child: ElevatedButton( style: ButtonStyle( backgroundColor: isTimerEnabled - ? WidgetStateProperty.all(Colors.green) - : WidgetStateProperty.all(Colors.red), + ? WidgetStateProperty.all(Colors.green as Size) + : WidgetStateProperty.all(Colors.red as Size), ), onPressed: () { setState(() { diff --git a/lib/pages/modules/flowers.dart b/lib/pages/modules/flowers.dart index 7b7e442..9ea0a27 100644 --- a/lib/pages/modules/flowers.dart +++ b/lib/pages/modules/flowers.dart @@ -17,49 +17,60 @@ class FlowerPage extends StatefulWidget { class _FlowerPageState extends State { final List flowers = [ Flower( - name: "Rose", - resource: AssetsPath.getFlowerImage(Flowers.rose), - background: Colors.redAccent), + name: "Rose", + resource: AssetsPath.getFlowerImage(Flowers.rose), + background: Colors.redAccent, + ), Flower( - name: "Sunflower", - resource: AssetsPath.getFlowerImage(Flowers.sunflower), - background: Colors.yellowAccent), + name: "Sunflower", + resource: AssetsPath.getFlowerImage(Flowers.sunflower), + background: Colors.yellowAccent, + ), Flower( - name: "Lily", - resource: AssetsPath.getFlowerImage(Flowers.lily), - background: Colors.greenAccent), + name: "Lily", + resource: AssetsPath.getFlowerImage(Flowers.lily), + background: Colors.greenAccent, + ), Flower( - name: "Marigold", - resource: AssetsPath.getFlowerImage(Flowers.marigold), - background: Colors.yellow), + name: "Marigold", + resource: AssetsPath.getFlowerImage(Flowers.marigold), + background: Colors.yellow, + ), Flower( - name: "Carnation", - resource: AssetsPath.getFlowerImage(Flowers.carnation), - background: Colors.redAccent), + name: "Carnation", + resource: AssetsPath.getFlowerImage(Flowers.carnation), + background: Colors.redAccent, + ), Flower( - name: "Daffodil", - resource: AssetsPath.getFlowerImage(Flowers.daffodil), - background: Colors.purpleAccent), + name: "Daffodil", + resource: AssetsPath.getFlowerImage(Flowers.daffodil), + background: Colors.purpleAccent, + ), Flower( - name: "Daisy", - resource: AssetsPath.getFlowerImage(Flowers.daisy), - background: Colors.green), + name: "Daisy", + resource: AssetsPath.getFlowerImage(Flowers.daisy), + background: Colors.green, + ), Flower( - name: "Poppy", - resource: AssetsPath.getFlowerImage(Flowers.poppy), - background: Colors.redAccent), + name: "Poppy", + resource: AssetsPath.getFlowerImage(Flowers.poppy), + background: Colors.redAccent, + ), Flower( - name: "Tulip", - resource: AssetsPath.getFlowerImage(Flowers.tulip), - background: Colors.pink), + name: "Tulip", + resource: AssetsPath.getFlowerImage(Flowers.tulip), + background: Colors.pink, + ), Flower( - name: "Lavender", - resource: AssetsPath.getFlowerImage(Flowers.lavender), - background: Colors.purple), + name: "Lavender", + resource: AssetsPath.getFlowerImage(Flowers.lavender), + background: Colors.purple, + ), Flower( - name: "Hibiscus", - resource: AssetsPath.getFlowerImage(Flowers.hibiscus), - background: Colors.red), + name: "Hibiscus", + resource: AssetsPath.getFlowerImage(Flowers.hibiscus), + background: Colors.red, + ), ]; final FlutterTts flutterTts = FlutterTts(); @@ -83,6 +94,7 @@ class _FlowerPageState extends State { await flutterTts.setPitch(1.0); await flutterTts.speak(name); } + void _navigateToFlowersTestPage(BuildContext context) { Navigator.push( context, @@ -93,6 +105,10 @@ class _FlowerPageState extends State { @override Widget build(BuildContext context) { Flower flower = flowers[currentIndex]; + String flowerImagePath = flower.resource; + // ignore: avoid_print + print('Flower image path: $flowerImagePath'); // Debug print + return Scaffold( appBar: AppBar( title: const Text( @@ -138,7 +154,7 @@ class _FlowerPageState extends State { width: double.infinity, height: 300, child: SvgPicture.asset( - flower.resource, + flowerImagePath, fit: BoxFit.contain, ), ), diff --git a/lib/pages/modules/seasons.dart b/lib/pages/modules/seasons.dart index cd19bd9..f4fe077 100644 --- a/lib/pages/modules/seasons.dart +++ b/lib/pages/modules/seasons.dart @@ -3,6 +3,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:learn/models/season_model.dart'; +import 'package:learn/pages/fruits.dart'; import 'package:learn/utils/constants.dart'; import '../../utils/const_dimensions.dart'; @@ -136,7 +137,7 @@ class _SeasonPopupState extends State { ), ElevatedButton( style: ButtonStyle( - backgroundColor: WidgetStateProperty.all(Colors.red), + backgroundColor: WidgetStateProperty.all(Colors.red as Size), ), onPressed: () { Navigator.of(context).pop(); From 3fa64853be78bd75ff173bda8fda35cbd7028d29 Mon Sep 17 00:00:00 2001 From: NamrataCSalvi <147251955+NamrataCSalvi@users.noreply.github.com> Date: Tue, 4 Jun 2024 18:13:47 +0530 Subject: [PATCH 4/9] no route error resolved The error in flowers.dart and flowers_test.dart file is solved along with no route error --- lib/main.dart | 2 +- lib/pages/explore/drawingboard.dart | 79 +++++++++++++---------------- lib/pages/main_home.dart | 2 +- lib/pages/modules/animals_test.dart | 1 + lib/pages/modules/birds_test.dart | 1 + lib/pages/modules/flowers_test.dart | 1 + lib/pages/modules/parts_test.dart | 1 + lib/pages/modules/planets_test.dart | 1 + lib/utils/assets_path.dart | 4 ++ lib/utils/route/route_constant.dart | 2 +- lib/utils/route/routes.dart | 2 + lib/widgets/drawer.dart | 1 + 12 files changed, 51 insertions(+), 46 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index d7f3bd0..f3b3b3c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -26,4 +26,4 @@ class MyApp extends StatelessWidget { onGenerateRoute: Routers.generateRoute, ); } -} \ No newline at end of file +} diff --git a/lib/pages/explore/drawingboard.dart b/lib/pages/explore/drawingboard.dart index b3c33de..4bf2e8f 100644 --- a/lib/pages/explore/drawingboard.dart +++ b/lib/pages/explore/drawingboard.dart @@ -1,13 +1,16 @@ +// ignore_for_file: library_private_types_in_public_api + import 'dart:ui'; + import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; class DrawingBoardPage extends StatelessWidget { - const DrawingBoardPage({Key? key}); + const DrawingBoardPage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return DrawingBoard(); + return const DrawingBoard(); } } @@ -20,7 +23,7 @@ class DrawingBoard extends StatefulWidget { class _DrawingBoardState extends State { Color selectedColor = Colors.black; - double strokeWidth = 5; + double strokeWidth = 5.0; bool isEraser = false; List drawingPoints = []; List colors = [ @@ -38,22 +41,20 @@ class _DrawingBoardState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text("Drawing Board"), + title: const Text("Drawing Board"), actions: [ TextButton.icon( onPressed: () => setState(() => drawingPoints = []), - icon: Icon(Icons.clear), - label: Text("Clear Board"), + icon: const Icon(Icons.clear), + label: const Text("Clear Board"), style: TextButton.styleFrom( - backgroundColor: Color(0xfff7f2fa), + foregroundColor: Colors.black, // Changed for better visibility + backgroundColor: const Color(0xfff7f2fa), ), - ), - SizedBox( - width: 10, ), + const SizedBox(width: 10), ], - ), - + ), body: Stack( children: [ GestureDetector( @@ -63,7 +64,7 @@ class _DrawingBoardState extends State { DrawingPoint( details.localPosition, Paint() - ..color = isEraser? Color(0xfffef7ff) : selectedColor + ..color = isEraser ? const Color(0xfffef7ff) : selectedColor ..isAntiAlias = true ..strokeWidth = strokeWidth ..strokeCap = StrokeCap.round, @@ -71,14 +72,13 @@ class _DrawingBoardState extends State { ); }); }, - onPanUpdate: (details) { setState(() { drawingPoints.add( DrawingPoint( details.localPosition, Paint() - ..color = isEraser? Color(0xfffef7ff) : selectedColor + ..color = isEraser ? const Color(0xfffef7ff) : selectedColor ..isAntiAlias = true ..strokeWidth = strokeWidth ..strokeCap = StrokeCap.round, @@ -86,72 +86,65 @@ class _DrawingBoardState extends State { ); }); }, - onPanEnd: (details) { setState(() { drawingPoints.add(null); }); }, - child: CustomPaint( painter: _DrawingPainter(drawingPoints), - child: Container( + child: SizedBox( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, ), ), ), - Positioned( top: 20, right: 10, left: 10, child: Row( children: [ - Slider( - min: 0, - max: 40, - value: strokeWidth, - onChanged: (val) => setState(() => strokeWidth = val), - ), - SizedBox( - width: 50 + Expanded( + child: Slider( + min: 0, + max: 40, + value: strokeWidth, + onChanged: (val) => setState(() => strokeWidth = val), + ), ), + const SizedBox(width: 10), ElevatedButton.icon( onPressed: () { setState(() { - isEraser =!isEraser; + isEraser = !isEraser; if (isEraser) { - selectedColor = Color(0xfffef7ff); + selectedColor = const Color(0xfffef7ff); } }); }, - icon: Icon(FontAwesomeIcons.eraser), - label: Text("Eraser"), + icon: const Icon(FontAwesomeIcons.eraser), + label: const Text("Eraser"), ), ], ), ), ], ), - bottomNavigationBar: BottomAppBar( child: Container( color: Colors.grey[200], - padding: EdgeInsets.all(10), + padding: const EdgeInsets.all(10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: List.generate( - colors.length, - (index) => _buildColorChoser(colors[index]), - ), + children: colors.map((color) => _buildColorChooser(color)).toList(), ), ), ), ); } - GestureDetector _buildColorChoser(Color color) { + GestureDetector _buildColorChooser(Color color) { bool isSelected = selectedColor == color; return GestureDetector( onTap: () { @@ -168,9 +161,9 @@ class _DrawingBoardState extends State { shape: BoxShape.circle, border: isSelected ? Border.all( - color: Colors.white, - width: 3, - ) + color: Colors.white, + width: 3, + ) : null, ), ), @@ -207,8 +200,8 @@ class _DrawingPainter extends CustomPainter { } class DrawingPoint { - Offset offset; - Paint paint; + final Offset offset; + final Paint paint; DrawingPoint(this.offset, this.paint); } diff --git a/lib/pages/main_home.dart b/lib/pages/main_home.dart index 6a61d01..602fa21 100644 --- a/lib/pages/main_home.dart +++ b/lib/pages/main_home.dart @@ -1,4 +1,4 @@ -// ignore_for_file: deprecated_member_use + import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:flutter/material.dart'; diff --git a/lib/pages/modules/animals_test.dart b/lib/pages/modules/animals_test.dart index 161cd6e..2bc5200 100644 --- a/lib/pages/modules/animals_test.dart +++ b/lib/pages/modules/animals_test.dart @@ -155,6 +155,7 @@ class _AnimalsTestPageState extends State { child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); + Navigator.of(context).pop(); }, ), ], diff --git a/lib/pages/modules/birds_test.dart b/lib/pages/modules/birds_test.dart index 5208242..ec40af0 100644 --- a/lib/pages/modules/birds_test.dart +++ b/lib/pages/modules/birds_test.dart @@ -175,6 +175,7 @@ class _BirdsTestPageState extends State { child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); + Navigator.of(context).pop(); }, ), ], diff --git a/lib/pages/modules/flowers_test.dart b/lib/pages/modules/flowers_test.dart index 764b7bb..d2f49aa 100644 --- a/lib/pages/modules/flowers_test.dart +++ b/lib/pages/modules/flowers_test.dart @@ -150,6 +150,7 @@ class _FlowersTestPageState extends State { child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); + Navigator.of(context).pop(); }, ), ], diff --git a/lib/pages/modules/parts_test.dart b/lib/pages/modules/parts_test.dart index 9b734be..a59824c 100644 --- a/lib/pages/modules/parts_test.dart +++ b/lib/pages/modules/parts_test.dart @@ -191,6 +191,7 @@ class _PartsTestPageState extends State { child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); + Navigator.of(context).pop(); }, ), ], diff --git a/lib/pages/modules/planets_test.dart b/lib/pages/modules/planets_test.dart index 7e1b1cf..f726ed4 100644 --- a/lib/pages/modules/planets_test.dart +++ b/lib/pages/modules/planets_test.dart @@ -140,6 +140,7 @@ class _PlanetsTestPageState extends State { child: const Text('Close'), onPressed: () { Navigator.of(context).pop(); + Navigator.of(context).pop(); }, ), ], diff --git a/lib/utils/assets_path.dart b/lib/utils/assets_path.dart index 0cebf9c..255a61c 100644 --- a/lib/utils/assets_path.dart +++ b/lib/utils/assets_path.dart @@ -256,6 +256,10 @@ class Flowers { static const String dandelion = 'dandelion.svg'; static const String jasmine = 'jasmine.svg'; static const String lotus = 'lotus.svg'; + static const String carnation= 'carnation.svg'; + static const String poppy= 'poppy.svg'; + static const String daffodil = 'daffodil.svg'; + } class SolarSystem { diff --git a/lib/utils/route/route_constant.dart b/lib/utils/route/route_constant.dart index 788a35d..be739c1 100644 --- a/lib/utils/route/route_constant.dart +++ b/lib/utils/route/route_constant.dart @@ -18,5 +18,5 @@ class AllRoutesConstant { static const String fruitRoute = "/fruit"; static const String drawingboardRoute = "/drawingboard"; static const String landingRoute = '/landing_page'; - static const String mainhomeRoute = '/mainhome'; + static const String mainhomeRoute = '/main_home'; } diff --git a/lib/utils/route/routes.dart b/lib/utils/route/routes.dart index 38f1a82..b43f5ff 100644 --- a/lib/utils/route/routes.dart +++ b/lib/utils/route/routes.dart @@ -60,6 +60,8 @@ class Routers { return slidePageRoute(const DrawingBoardPage()); case AllRoutesConstant.landingRoute: return slidePageRoute(const LandingPage()); + case AllRoutesConstant.mainhomeRoute: + return slidePageRoute(const MainHome()); default: diff --git a/lib/widgets/drawer.dart b/lib/widgets/drawer.dart index d4d063f..108eb0e 100644 --- a/lib/widgets/drawer.dart +++ b/lib/widgets/drawer.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; // import 'package:flutter_svg/flutter_svg.dart'; +// ignore: unused_import import 'package:learn/utils/assets_path.dart'; import 'package:learn/utils/route/route_constant.dart'; From 6b0213ef623839737bbed8daf9c5d54680150adc Mon Sep 17 00:00:00 2001 From: NamrataCSalvi <147251955+NamrataCSalvi@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:16:47 +0530 Subject: [PATCH 5/9] made required changes --- lib/main.dart | 1 + lib/pages/explore/explore.dart | 1 + lib/pages/home.dart | 2 ++ lib/pages/modules/atoz.dart | 3 +-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 910c5aa..5fce5bf 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,6 +3,7 @@ import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:learn/landing_page.dart'; import 'package:learn/utils/route/routes.dart'; import 'package:learn/theme_provider.dart'; +// ignore: depend_on_referenced_packages import 'package:provider/provider.dart'; DateTime? currentBackPressTime; diff --git a/lib/pages/explore/explore.dart b/lib/pages/explore/explore.dart index 22c2f5a..e228c7e 100644 --- a/lib/pages/explore/explore.dart +++ b/lib/pages/explore/explore.dart @@ -145,6 +145,7 @@ class _ExplorePageState extends State { } } catch (e) { + // ignore: avoid_print print(e); } }, diff --git a/lib/pages/home.dart b/lib/pages/home.dart index 9375deb..f2d4f37 100644 --- a/lib/pages/home.dart +++ b/lib/pages/home.dart @@ -1,8 +1,10 @@ +// ignore: unused_import import 'package:adaptive_theme/adaptive_theme.dart'; import 'package:flutter/material.dart'; import 'package:learn/utils/assets_path.dart'; import 'package:learn/utils/const_dimensions.dart'; import 'package:learn/utils/route/route_constant.dart'; +// ignore: depend_on_referenced_packages import 'package:provider/provider.dart'; import '../widgets/drawer.dart'; import '../theme_provider.dart'; diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index e3eefbe..20a5e5e 100644 --- a/lib/pages/modules/atoz.dart +++ b/lib/pages/modules/atoz.dart @@ -214,8 +214,7 @@ class _PopupDialogState extends State<_PopupDialog> { child: const Text('Next'), ), ], - ), - + ), ], ), From 33c32f6bf7496530a3556a18b4ee59fd1bcd8388 Mon Sep 17 00:00:00 2001 From: NamrataCSalvi <147251955+NamrataCSalvi@users.noreply.github.com> Date: Sun, 23 Jun 2024 19:21:48 +0530 Subject: [PATCH 6/9] errors resolved in android file --- android/gradle/wrapper/gradle-wrapper.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..5ae2905 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Sun Jun 23 18:56:31 IST 2024 distributionBase=GRADLE_USER_HOME +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +zipStoreBase=GRADLE_USER_HOME From 2c10ab09fd5d4cf91e01827009c56a66e1ffb123 Mon Sep 17 00:00:00 2001 From: Sapate Vaibhav Date: Fri, 28 Jun 2024 19:39:54 +0530 Subject: [PATCH 7/9] Fixed quiz related issue --- lib/pages/explore/explore.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/pages/explore/explore.dart b/lib/pages/explore/explore.dart index e228c7e..9061223 100644 --- a/lib/pages/explore/explore.dart +++ b/lib/pages/explore/explore.dart @@ -44,7 +44,7 @@ class _ExplorePageState extends State { [ GestureDetector( onTap: () { - Navigator.push(context, (MaterialPageRoute(builder: (context) => const QuizPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const Quiz()))); }, child: Container( margin: const EdgeInsets.all(5.0), @@ -120,7 +120,7 @@ class _ExplorePageState extends State { try{ switch (index) { case 0: - Navigator.push(context, (MaterialPageRoute(builder: (context) => const QuizPage()))); + Navigator.push(context, (MaterialPageRoute(builder: (context) => const Quiz()))); break; case 1: Navigator.push(context, (MaterialPageRoute(builder: (context) => const AtoZ()))); @@ -233,4 +233,4 @@ class _ExplorePageState extends State { ), ); } -} \ No newline at end of file +} From b734e753a28c4818a922c3a095f47af413001d65 Mon Sep 17 00:00:00 2001 From: Sapate Vaibhav Date: Fri, 28 Jun 2024 19:41:04 +0530 Subject: [PATCH 8/9] Update atoz.dart --- lib/pages/modules/atoz.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pages/modules/atoz.dart b/lib/pages/modules/atoz.dart index 20a5e5e..f7678ec 100644 --- a/lib/pages/modules/atoz.dart +++ b/lib/pages/modules/atoz.dart @@ -255,8 +255,8 @@ class _AtoZState extends State { child: ElevatedButton( style: ButtonStyle( backgroundColor: isTimerEnabled - ? WidgetStateProperty.all(Colors.green as Size) - : WidgetStateProperty.all(Colors.red as Size), + ? MaterialStateProperty.all(Colors.green) + : MaterialStateProperty.all(Colors.red ), ), onPressed: () { setState(() { From c3946936cc6a7f9aef50d5984d6f30149de4fa91 Mon Sep 17 00:00:00 2001 From: Sapate Vaibhav Date: Fri, 28 Jun 2024 19:42:09 +0530 Subject: [PATCH 9/9] Update seasons.dart --- lib/pages/modules/seasons.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pages/modules/seasons.dart b/lib/pages/modules/seasons.dart index f4fe077..3ad143b 100644 --- a/lib/pages/modules/seasons.dart +++ b/lib/pages/modules/seasons.dart @@ -137,7 +137,7 @@ class _SeasonPopupState extends State { ), ElevatedButton( style: ButtonStyle( - backgroundColor: WidgetStateProperty.all(Colors.red as Size), + backgroundColor: MaterialStateProperty.all(Colors.red), ), onPressed: () { Navigator.of(context).pop();