Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qharny/python
https://github.com/qharny/python
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/qharny/python
- Owner: Qharny
- Created: 2023-09-02T23:28:54.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-12T15:36:19.000Z (about 1 year ago)
- Last Synced: 2023-10-14T07:16:37.012Z (about 1 year ago)
- Language: Python
- Size: 846 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
1. First, we import the necessary libraries. In this case, we only need the `flutter` library.
```
import 'package:flutter/material.dart';
```2. Next, we define the main function. This function is the entry point of our application.
```
void main() {
runApp(SimpleQuizApp());
}
```3. The `SimpleQuizApp` class is the root of our application. It extends the `StatelessWidget` class, which means that it does not have any state.
```
class SimpleQuizApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Simple Quiz App',
home: QuizScreen(),
);
}
}
```4. The `QuizScreen` class is the main screen of our application. It extends the `StatefulWidget` class, which means that it has state. The state of the `QuizScreen` class is the current question and answer.
```
class QuizScreen extends StatefulWidget {
@override
_QuizScreenState createState() => _QuizScreenState();
}class _QuizScreenState extends State {
// Define your quiz questions and answers here
List> questions = [
{
'questionText': 'What is 2 + 2?',
'answers': [
{'text': '3', 'correct': false},
{'text': '4', 'correct': true},
{'text': '5', 'correct': false},
],
},
{
'questionText': 'What is the capital of France?',
'answers': [
{'text': 'Berlin', 'correct': false},
{'text': 'Madrid', 'correct': false},
{'text': 'Paris', 'correct': true},
],
},
];int _questionIndex = 0;
int _score = 0;void _answerQuestion(bool isCorrect) {
setState(() {
if (isCorrect) {
_score++;
}
_questionIndex++;
});
}@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: