Skip to content

A boilerplate project created in Flutter using Riverpod and Firebase with clean-architecture, utility functions(errorTracker, eventTracker)

License

Notifications You must be signed in to change notification settings

swarajkumarsingh/flutter_boilerplate_project

Repository files navigation

Flutter Boilerplate Project

This is a boilerplate Flutter project that demonstrates best practices for setting up a project with Riverpod, including various essential packages for common tasks.

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:

  • more optimizations and utilities files

Features

  • 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

Dependencies

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.

App Flow Chart


CallFlow


How to Use

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

Configuration

Firebase

To enable Firebase services (Analytics, Crashlytics, Performance), follow these steps:

  1. Create a Firebase project in the Firebase Console.

  2. Use firebase-cli to change the google-service.json file

Sentry

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.

Folder structure

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)

Create a immutable Model with any features available

  • Define a constructor + the properties
  • Override toString, operator ==, hashCode
  • Implement a copyWith method to clone the object
  • Handling de/serialization

Example

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);
}

Implement

final DogImage dogImage = DogImage.fromJson(json);
///
final DogImage dogImage = dogImage.copyWith(status: 'failed');
/// Deep copy, equal operator ...
...

flutter_native_splash

To create splash, execute the following command: dart run flutter_native_splash:create

License

This boilerplate is MIT licensed.

Contributing

Contributions are welcome! If you find a bug or want to add a new feature, please open an issue or submit a pull request.

About

A boilerplate project created in Flutter using Riverpod and Firebase with clean-architecture, utility functions(errorTracker, eventTracker)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages