👨🔧 Created by : Yusril Rapsanjani
- Domain-Driven Design (DDD): Organizes code into logical layers for maintainability and scalability.
- Freezed: Utilized for immutable data classes and sealed classes, reducing boilerplate code.
- BLoC / Cubit: Implements state management using the BLoC pattern for a clear separation of concerns.
- AutoRoute: Provides automatic route generation and navigation management.
- Multiple Variants: Supports multiple environments (
dev
,staging
,prod
) to facilitate testing and deployment. - Dependency Injection: Ensures modular and testable code structure.
- Error Handling: Centralized error handling using
Failure
andResponseCode
for better debugging and UX.
This template serves as a solid foundation for developing scalable and maintainable Flutter applications. 🚀
➡️ Flutter 3.29.0
➡️ Dart 3.7.0
lib
│── bloc
│── config
│── core
│ │── components
│ │── constant
│ │── models
│ │── networks
│── domain
│ │── entities
│ │── models
│ │── repositories
│── gen
│── infrastructure
│ │── datasource
│ │── repositories
│── injection
│── presentation
│── routing
│── theme
│── utils
│── app.dart
│── bootstrap.dart
│── main.dart
- First you need to install copy_template to generate project based on name
dart pub global activate copy_template
- Install to specific directory on your pc with your project name
copy_template <project_name> https://github.com/yusriltakeuchi/flutter_template.git <path>
For example:
copy_template my_app https://github.com/yusriltakeuchi/flutter_template.git /Users/mac/Documents/FLUTTER_PROJECT
You can change the package name by running the command below
dart run change_app_package_name:main com.package.name
- Change name in
android/app/build.gradle
->productFlavors
- Then change package name in
utils/flavor/flavor_utils.dart
- Create
key.properties
file inandroid
directory with the following content:
storePassword=yourpassword
keyPassword=yourpassword
keyAlias=youralias
storeFile=yourfilelocation.jks
- Place your keystore .jks file in storeFile setting location
You can choose to run your project with various variant, currently available is dev
, staging
, and prod
.
flutter run --flavor dev
You can access the flavor variant by using FlavorUtils
class
flavor.current
- You need to create a page on
presentation
directory - Add the
@RoutePage()
annotation in your screen class, example:
@RoutePage()
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Home Screen',
style: MyTheme.style.title.copyWith(
color: MyTheme.color.white,
fontSize: AppSetting.setFontSize(45)
),
),
automaticallyImplyLeading: false,
backgroundColor: MyTheme.color.primary,
),
body: BlocProvider(
create: (context) => UserBloc()..getUsers(params: {'page': 1}),
child: const HomeBody(),
),
);
}
}
- Run the make file to generate the code
make runner-build
- open
route.dart
file and add your page into routes variables.
@override
List<AutoRoute> get routes => [
AutoRoute(page: SplashRoute.page, initial: true),
AutoRoute(page: HomeRoute.page),
];
You can listen to the mode by using BlocBuilder into ThemeBloc. There are three modes available, light
, dark
, and system
.
- Create Entity class in
domain/entities
- Create APIExtension in
infrastructure/datasource/base/api_datasource_ext.dart
- Create DataSource in
infrastructure/datasource
- Create Abstract Class Repository in
domain/repositories
- Create Repository Implementation in
infrastructure/repositories
- Inject DataSource & Repository in
injection
- Create Bloc Cubit in
bloc
- Create Pages in
presentation
How to install:
- Download the file template
- Open IntelliJ IDEA
- Go to
File
->Manage IDE Settings
->Import Settings...
- Choose the file template that you have downloaded
- Create new file and you will see the following options.
♻️ assets_cleaner - A command-line tool wich helps you to clean your assets folder. It will remove all files that are not used in your project.