The code implements a basic Flutter application with a login page and a simple card-matching game. Here's a breakdown:
### Main Structure
1. **MyApp (StatefulWidget)**: The main application widget. It controls the theme (dark or light) and whether the user is logged in or not. Based on the `_isLoggedIn` state, it either shows the login screen or the game screen.
### Login Screen
2. **Login (StatelessWidget)**: The login screen. It contains a background image and a welcome message, along with a "Start Game" button that triggers the `onLogin` callback when pressed. There is also an "Exit" button that triggers the `onExit` callback, displaying a confirmation dialog before exiting.
### CombinedExampleApp
3. **CombinedExampleApp (StatelessWidget)**: This is the main game screen with a `TabBar` that switches between the "Picture Matching" and "Score" tabs. It also includes a switch to toggle between dark and light themes and a settings menu in the app bar.
### Picture Matching Game
4. **PictureMatchingPage (StatefulWidget)**: The card-matching game. It displays two random images, and the user needs to press on them to check if they match. If the images match, the score increases, and a message is shown via a `SnackBar`. It also tracks the number of attempts.
### Score Display
5. **TabBarDemo (StatelessWidget)**: This tab displays the user's current score, using a `ValueListenableBuilder` to listen for changes to the score stored in the `scoreNotifier`.
### Exit Confirmation
6. **MyButton (StatelessWidget)**: This is the custom button that shows an exit confirmation dialog when pressed. If the user confirms, the game exits, returning to the login screen.
### Additional Features
- **Theme Switching**: The `Switch` widget in the app bar allows the user to toggle between dark and light modes.
- **PopupMenu**: A `PopupMenuButton` provides several options like "Preview," "Share," etc., but these are not yet implemented.
The code integrates various Flutter features like `Scaffold`, `AppBar`, `SnackBar`, `Dialog`, and navigation using `Navigator.of(context).pop()`.
اسم المستقل | Ahmed H. |
عدد الإعجابات | 0 |
عدد المشاهدات | 5 |
تاريخ الإضافة | |
تاريخ الإنجاز |