This is a boilerplate Flutter project that demonstrates best practices for setting up a project with Riverpod, including various essential packages for common tasks.
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.
- more optimizations and utilities files
- Custom Logging
- Custom Routing (without context)
- Custom Snackbar & Toast (without context)
- Local storage
- Code generation
- Analysis template
- Clean architecture
- Sentry Crashlytics
- Dependency Injection
- Firebase Performance
- Crashlytics template
- Local database and examples
- Api integration and examples
- State management with riverpod and examples
This boilerplate includes several common dependencies that you may find useful when building your application:
Packages | Description |
---|---|
Dio | REST Api calls |
intl | Internationalization and Localization |
riverpod | State Manager |
freezed | Code generation for models |
logger | Logger |
App Router | Approuter (without context) |
json_serializable | Code generation for converting to and from JSON |
SharedPreferences | Native splash screen |
Dependency Injection | For Dependency Injection |
Firebase analysis | For firebase_analytics |
firebase Performance | For firebase_crashlytics |
firebase Crashlytics | For firebase_crashlytics |
Sentry Crashlytics | For Crashlytics |
cached_network_image | Load and cache network images |
flutter_native_splash | Native splash screen |
You can add or remove dependencies as needed for your specific use case.
Step 1:
Fork, download or clone this repo by using the link below:
git clone https://github.com/swarajkumarsingh/flutter_boilerplate_project.git
cd flutter_boilerplate_project
Step 2: Go to project root and execute the following command in terminal to get the required dependencies and generate languages, freezed, flutter gen:
flutter pub get
Step 3: Change the project name from pubspec.yaml, AndroidManifest.xml, and build.gradle
Step 4: Change sentryDSN variable from the constants.dart file
To enable Firebase services (Analytics, Crashlytics, Performance), follow these steps:
-
Create a Firebase project in the Firebase Console.
-
Use firebase-cli to change the google-service.json file
To set up Sentry for error tracking, create an account on Sentry.io, create a new project, and follow the setup instructions provided on the Sentry dashboard.
flutter_boilerplate_project/
|- assets/ (assets)
|- android/ (android)
|- ios/ (ios)
|- tools/ (custom tools)
|- lib/
|- core/ (Riverpod observer, theme,...)
|- common/ (common files)
|- configs/ (app config)
|- constants/ (app constants)
|- di/ (dependency injection)
|- dio/ (custom dio class)
|- event_tracker/ (firebase, sentry event tracker)
|- error_tracker/ (firebase, sentry error tracker)
|- utils/ (utility files)
|- data/ (repository)
|- data_source/ (app's main logic source)
|- db/ (local db)
|- local/ (local files)
|- providers/ (providers files)
|- repository/ (repository implementation files)
|- service/ (service files)
|- domain/ (domain)
|- models/ (models)
|- repository/ (repository)
|- presentation/ (repository)
|- view/ (app screen)
|- viewModel/ (views's viewModel)
|- widgets/ (views's widgets)
|- my_app.dart/ (my_app file)
|- main.dart/ (main file)
- Define a
constructor
+ theproperties
- Override
toString
, operator==
, hashCode - Implement a
copyWith
method to clone the object - Handling
de/serialization
part 'dog_image.freezed.dart';
part 'dog_image.g.dart';
@Freezed(fromJson: true)
class DogImage with _$DogImage {
const factory DogImage({
required String message,
required String status,
}) = _DogImage;
factory DogImage.fromJson(Map<String, dynamic> json) =>
_$DogImageFromJson(json);
}
final DogImage dogImage = DogImage.fromJson(json);
///
final DogImage dogImage = dogImage.copyWith(status: 'failed');
/// Deep copy, equal operator ...
...
To create splash, execute the following command: dart run flutter_native_splash:create
This boilerplate is MIT licensed.
Contributions are welcome! If you find a bug or want to add a new feature, please open an issue or submit a pull request.