This commit is contained in:
2024-02-06 15:57:30 +01:00
parent 9741b5530d
commit ea751d1616
17 changed files with 81 additions and 12 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.2\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.2.1\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-02-06 10:07:28.023270","version":"3.16.9"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.2.2\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.3.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.2.1\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\birkeh\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.2.1\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2024-02-06 15:11:32.548844","version":"3.16.9"}
File diff suppressed because one or more lines are too long
@@ -1,4 +1,4 @@
#Tue Feb 06 10:09:06 CET 2024
#Tue Feb 06 15:11:46 CET 2024
base.0=C\:\\Users\\birkeh\\Documents\\GitHub\\flutter\\Lerne Flutter\\The Complete Guide (2024 Edition)\\adv_basics\\build\\app\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
renamed.0=classes.dex
path.0=classes.dex
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
8498af6ce7d41a64005cd58cbf61fa20ee76876b
8b61c173208760c85ed14ca08c3888d4649744f8
+39
View File
@@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
class QuestionsSummary extends StatelessWidget {
const QuestionsSummary(this.summaryData, {super.key});
final List<Map<String, Object>> summaryData;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 300,
child: SingleChildScrollView(
child: Column(
children: summaryData.map(
(data) {
return Row(
children: [
Text(((data['question_index'] as int) + 1).toString()),
Expanded(
child: Column(
children: [
Text(data['question'] as String),
SizedBox(
height: 5,
),
Text(data['user_answer'] as String),
Text(data['correct_answer'] as String),
],
),
),
],
);
},
).toList(),
),
),
);
}
}
+1 -2
View File
@@ -28,7 +28,6 @@ class _QuizState extends State<Quiz> {
if (selectedAnswers.length == questions.length) {
setState(() {
selectedAnswers = [];
activeScreen = 'results-screen';
});
}
@@ -45,7 +44,7 @@ class _QuizState extends State<Quiz> {
}
if (activeScreen == 'results-screen') {
screenWidget = const ResultsScreen();
screenWidget = ResultsScreen(chosenAnswers: selectedAnswers);
}
return MaterialApp(
home: Scaffold(
+34 -3
View File
@@ -1,10 +1,40 @@
import 'package:flutter/material.dart';
import 'package:adv_basics/data/questions.dart';
import 'package:adv_basics/questions_summary.dart';
class ResultsScreen extends StatelessWidget {
const ResultsScreen({super.key});
const ResultsScreen({
super.key,
required this.chosenAnswers,
});
final List<String> chosenAnswers;
List<Map<String, Object>> getSummaryData() {
final List<Map<String, Object>> summary = [];
for (var i = 0; i < chosenAnswers.length; i++) {
summary.add(
{
'question_index': i,
'question': questions[i].text,
'correct_answer': questions[i].answers[0],
'user_answer': chosenAnswers[i],
},
);
}
return summary;
}
@override
Widget build(BuildContext context) {
final summaryData = getSummaryData();
final numTotalQuestions = questions.length;
final numCorrectQuestions = summaryData.where((data) {
return data['user_answer'] == data['correct_answer'];
}).length;
return SizedBox(
width: double.infinity,
child: Container(
@@ -12,11 +42,12 @@ class ResultsScreen extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('You answered X out of Y questions correctly!'),
Text(
'You answered $numCorrectQuestions out of $numTotalQuestions questions correctly!'),
const SizedBox(
height: 30,
),
const Text('List of answers and questions...'),
QuestionsSummary(summaryData),
const SizedBox(
height: 30,
),