initial commit

This commit is contained in:
2024-02-03 20:27:45 +01:00
commit e9a0204004
676 changed files with 10559 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import 'package:adv_basics/models/quiz_question.dart';
const questions = [
QuizQuestion(
'What are the main building blocks of Flutter UIs?',
[
'Widgets',
'Components',
'Blocks',
'Functions',
],
),
QuizQuestion('How are Flutter UIs built?', [
'By combining widgets in code',
'By combining widgets in a visual editor',
'By defining widgets in config files',
'By using XCode for iOS and Android Studio for Android',
]),
QuizQuestion(
'What\'s the purpose of a StatefulWidget?',
[
'Update UI as data changes',
'Update data as UI changes',
'Ignore data changes',
'Render UI that does not depend on data',
],
),
QuizQuestion(
'Which widget should you try to use more often: StatelessWidget or StatefulWidget?',
[
'StatelessWidget',
'StatefulWidget',
'Both are equally good',
'None of the above',
],
),
QuizQuestion(
'What happens if you change data in a StatelessWidget?',
[
'The UI is not updated',
'The UI is updated',
'The closest StatefulWidget is updated',
'Any nested StatefulWidgets are updated',
],
),
QuizQuestion(
'How should you update data inside of StatefulWidgets?',
[
'By calling setState()',
'By calling updateData()',
'By calling updateUI()',
'By calling updateState()',
],
),
];
+7
View File
@@ -0,0 +1,7 @@
import 'package:adv_basics/quiz.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const Quiz());
}
+6
View File
@@ -0,0 +1,6 @@
class QuizQuestion {
const QuizQuestion(this.text, this.answers);
final String text;
final List<String> answers;
}
+17
View File
@@ -0,0 +1,17 @@
import 'package:flutter/material.dart';
class QuestionsScreen extends StatefulWidget {
const QuestionsScreen(void Function() switchScreen, {super.key});
@override
State<QuestionsScreen> createState() {
return _QuestionsScreenState();
}
}
class _QuestionsScreenState extends State<QuestionsScreen> {
@override
Widget build(context) {
return const Text('QuestionsScreen');
}
}
+51
View File
@@ -0,0 +1,51 @@
import 'package:adv_basics/questions_screen.dart';
import 'package:adv_basics/start_screen.dart';
import 'package:flutter/material.dart';
class Quiz extends StatefulWidget {
const Quiz({super.key});
@override
State<Quiz> createState() {
return _QuizState();
}
}
class _QuizState extends State<Quiz> {
var activeScreen = 'start-screen';
void switchScreen() {
setState(() {
activeScreen = 'questions-screen';
});
}
@override
Widget build(context) {
Widget screenWidget = StartScreen(switchScreen);
if (activeScreen == 'questions-screen') {
screenWidget = QuestionsScreen(switchScreen);
}
return MaterialApp(
home: Scaffold(
body: Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [
Color.fromARGB(255, 78, 13, 151),
Color.fromARGB(255, 107, 15, 168),
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
),
child: activeScreen == 'start-screen'
? StartScreen(switchScreen)
: QuestionsScreen(switchScreen),
),
),
);
}
}
+42
View File
@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
class StartScreen extends StatelessWidget {
const StartScreen(this.startQuiz, {super.key});
final void Function() startQuiz;
@override
Widget build(context) {
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Image.asset(
'assets/images/quiz-logo.png',
width: 300,
color: const Color.fromARGB(150, 255, 255, 255),
),
const SizedBox(
height: 80,
),
const Text(
'Learn Flutter the fun way!',
style: TextStyle(
color: Color.fromARGB(255, 237, 223, 252),
fontSize: 24,
),
),
const SizedBox(height: 30),
OutlinedButton.icon(
onPressed: startQuiz,
style: OutlinedButton.styleFrom(
foregroundColor: Colors.white,
),
icon: const Icon(Icons.arrow_right_alt),
label: const Text('Start Quiz'),
)
],
),
);
}
}