This is a boilerplate for Flutter projects. It's included:
- Install flutter_gen
dart pub global activate flutter_gen
- Languange template file is located at
lib/l10n/app_en.arb
- Tutorial
- Depends on flutter_flavorizr & flutter_dot_env
- Create your environments files in the root projects. eg
.production.env.
==Refer to .example.env==
app_name=Example App
domain=staging.something.com
base_url=https://$domain
api_v1=/api/v1
- Remember to exclude your environment files in .gitignore
- Configure your app environments in
pubspec.yaml
flavorizr:
flavors:
staging:
app:
name: "Staging App"
android:
applicationId: "com.staging.boilerplate"
ios:
bundleId: "com.staging.boilerplate"
production:
app:
name: "Production App"
android:
applicationId: "com.production.boilerplate"
ios:
bundleId: "com.production.boilerplate"
- Run this command on terminal to generate environments
flutter pub run flutter_flavorizr
- Delete unused generated files:
- pages/my_home_page.dart
- app.dart
- Change code in this files according to your envs:
// main_production.dart
void main() {
F.appFlavor = Flavor.PRODUCTION;
mainCommon();
}
//main_staging.dart
void main() {
F.appFlavor = Flavor.STAGING;
mainCommon();
}
// main.dart
// ..
// ..
if (F.appFlavor == Flavor.STAGING) {
await dotenv.load(
fileName: '.staging.env',
);
} else {
await dotenv.load(
fileName: '.production.env',
);
}
- You can access env variables from AppEnv class from
config/app_environments/app_env.dart
- Depends on get_it
- Inject your dependencies in
lib/core/injector.dart
- Depends on
- Depends on go_router
- Depends on all_lints_rules.yaml