Flutter Boilerplate Project
A boilerplate project created in flutter using Bloc, Retrofit. Depend on code generation.
Features
- State management and examples
- Api integration and examples
- Local database and examples
- Code generation
- Local storage
- Logging
- Routing
- Dependency Injection
- Crashlytics template
- DarkTheme
- Multi languages
- Unit tests
- Clean architecture
- Flutter CI
Some packages:
- Freezed
- Flutter Bloc
- Flutter gen
- Retrofit
- Dio
- Bloc test
- Mockito
- Go router
- Dependency Injection
- Logger
- Floor
- SharedPreferences
Getting Started
The Boilerplate contains the minimal implementation required to create a new library or project. The repository code is preloaded with some basic components like basic app architecture, app theme, constants and required dependencies to create a new project. By using boiler plate code as standard initializer, we can have same patterns in all the projects that will inherit it. This will also help in reducing setup & development time by allowing you to use same code pattern and avoid re-writing from scratch.
Up-Coming Features:
- Handle multi bloc event in the same time by bloc concurrency example
- Load more infinite list using bloc example
- Authentication template
Architecture

How to Use
Step 1:
Fork, download or clone this repo by using the link below:
https://github.com/zeref278/flutter_boilerplate.git
Step 2:
Go to project root and execute the following command in terminal to get the required dependencies and generate languages, freezed, flutter gen:
Step 3:
Go to /packages/rest_client
and execute the following command in terminal to generate model and api client:
Whenever change freezed file, assets, api
Run command
Folder structure
flutter_boilerplate/
|- asssets/ (assets)
|- lib/
|- common/ (dimens, spacing, theming)
|- config/ (flavor config)
|- data/ (repository)
|- features/ (features page)
|- generated/ (code generation includes localization and assets generation)
|- injector/ (dependencies injector)
|- l10n/ (localization resources
|- router/ (routing)
|- services/ (app services)
|- utils/ (app utils)
|- packages/
|- rest_client/ (api client)
|- local_database/ (local database)
|- tests/
|- app_test/ (mock dependencies)
|- features/ (bloc test features)
Freezed:
Create a immutable Model with any features available
- Define a
constructor
+ theproperties
- Override
toString
, operator==
, hashCode - Implement a
copyWith
method to clone the object - Handling
de/serialization
Example
Implement
Retrofit:
Create a api client by code generation, you do not need to implement each request manually
Example
Generate to
And this api client will use the baseUrl
from a Dio injector
Mockito and Bloc tests:
If a bloc that you want to test have a required dependencies, you must add it into annotations @GenerateMocks
in /test/app_test/app_test.dart
:
Run the following command to generate a mock dependency
Write a test file: