This project is a Flutter application with the following features and enhancements:
The codebase has been refactored into three separate files to improve maintainability:
main.dart: Contains only the entry point of the application.app.dart: Contains theMyAppwidget, which sets up the overall app configuration.home_page.dart: Contains theMyHomePagewidget and its state, representing the main screen of the app.
- Dark/Light Mode Toggle:
- Added a toggle action button to the
AppBarto switch between light and dark mode. - The theme state is managed in
MyHomePageand persisted usingshared_preferencesto ensure the selected theme is remembered across app restarts. - The theme management was further enhanced using
Riverpodfor state management.
- Added a toggle action button to the
- Widget Tests:
- Fixed errors in the test files and added new tests to verify the functionality of the theme changer button.
- Updated tests to reflect changes in theme management and state persistence.
- Added tests to ensure the
ThemeNotifiercorrectly toggles and persists the theme state usingshared_preferences.
- Language Selector:
- Added a language selector in the
AppBarfor English, German, Spanish, and French. - Used the
flutter_localizationspackage for internationalization. - Refactored all hardcoded text messages to use localized strings.
- The current selected language is displayed with its corresponding flag in the
AppBar. - Language selection is persisted using
shared_preferencesand managed viaRiverpod.
- Added a language selector in the
- Loading Indicator:
- Added a centered loading indicator that occupies 25% of the screen while the theme is being loaded.
- Updated App Title:
- The app's title has been updated to "Moinsen: Cursor Test."
- Generated Code:
- The project uses
build_runnerto generate necessary code forRiverpodproviders. - Ensure you run
flutter pub getandflutter pub run build_runner build --delete-conflicting-outputsafter cloning the repository or making changes to the providers.
- The project uses
To run this project, follow these steps:
-
Ensure you have Flutter (version 3.24.x) and Dart (version 3.5.x) installed on your system.
-
Clone the repository:
git clone https://github.com/your-username/moinsen-cursor-test.git cd moinsen-cursor-test -
Install dependencies:
flutter pub get -
Generate necessary code:
flutter pub run build_runner build --delete-conflicting-outputs -
Run the app:
flutter runThis will launch the app on your connected device or emulator.
-
To run tests:
flutter test
Note: Make sure you have a device connected or an emulator running before step 5.