This project is a starting point for a Flutter applications created by Worldline Spain.
- Clean Architecture
- Flavors (dev, prep, prod)
- Http client to Api REST (Dio)
- Native launch screen
- App icons configured
- Internationalization translations (Easy localization)
- Routing (Go Router)
- MVVM pattern with Cubit for state management
- Dependency injection (Get it and Injectable).
The application has three environments and each one has its own configuration file:
- dev:
.env/dev.dart
- prep:
.env/prep.dart
- prod:
.env/prod.dart
To configure a new project, you have change the following files:
- The environment files with the key and values.
- Replace the project name
worldline_flutter
in all files. - Replace the package name
com.worldline.flutter
in all files. - Remove all files with references to Example code.
- Refactor homeWorldline on
constants.dart
- Rename folder on
android/app/src/main/kotlin/
to your package name
- Replace the splash image
assets/images/splash-logo.png
with the new one. - Replace the splash android 12 image
assets/images/splash-android12-logo.png
with the new one. - Generate the splash images with the following command
fvm flutter pub run flutter_native_splash:create
- (optional) If you want use splash images in Flutter, replace the
assets/images/splash.png
and related images to accomplish the resolution aware asset. In yourandroid/app/src/main/res/drawable-mdpi
folder, you will have asplash.png
. This is your 1x image. reference Copy that to your app's assets folder. Then copy thesplash.png
inandroid/app/src/main/res/drawable-hdpi
to a subfolder in your app's assets folder named1.5x
. Do the same for the rest of the folders. The mapping should be:
mdpi
→assets
hdpi
→assets/1.5x
xhdpi
→assets/2.0x
xxhdpi
→assets/3.0x
xxxhdpi
→assets/4.0x
To run the application in each environment, you can use the following commands:
- dev:
flutter run --flavor dev --dart-define-from-file=.env/dev.json
- prep:
flutter run --flavor prep --dart-define-from-file=.env/prep.json
- prod:
flutter run --flavor prod --dart-define-from-file=.env/prod.json
Also, you can configure your IDE to run the application in each environment.
If you implement a new injectable file, you have to run the following command to generate the necessary code:
fvm flutter packages pub run build_runner build
or sh ./tools/generate_code.sh
Also, you can configure Android Studio to run this command automatically:
- On the configuration, add a new "External tool" execution step in the "before launch" section.
- Configure the execution step as follows:
- Name: injectable
- Description: Run injects before launch
- Program: flutter
- Arguments: packages pub run build_runner build
- Working directory:
$ProjectFileDir$
Is important to note that you have to configure the command for the three flavors.