Flutter Redux Starter
We're using this approach to develop our Flutter app for Invoice Ninja.
This codebase provide a sample for basic app initialization but there are also examples of using Redux to manage CRUD operations for REST APIs and supporting switching between multiple accounts.
Setup
- Clone/fork the repo
- Rename .env.dart.example to .env.dart
Features
- Supports large Redux stores by persisting parts separately
- App state (including navigation) is persisted on form changes
- The account email is also backed up in shared preferences
- All state and models classes are created using built_values
- Includes sample integration test configured with local settings
Basic Flow
- main.dart - The user is navigated to an initialization screen
- redux/app/app_middleware.dart - The app checks if there is a saved state
- ui/dashboard - If a state is found the user is taken to the dashboard
- ui/auth/login.dart - Otherwise, the user is navigated to the login screen
- redux/auth/auth_middleware.dart - When the user clicks login the app sends an API request
- ui/auth/login.dart - If there's a problem the error is shown on the login screen
- ui/dashboard - If the credentials are correct the user is logged in
Included Packages
- flutter_redux - Consume a Redux Store to build Flutter Widgets.
- redux_logging - Print the latest state\action changes.
- path_provider - Find commonly used locations on the filesystem.
- shared_preferences - Provides a persistent store for simple data.
- build_runner - A concrete way of generating files using Dart code.
- built_value - Built Values for Dart.
- built_collection - Built Collections for Dart.
Application Architecture
The architecture is based off these two projects: