This is a Flutter project template that comes fully configured with some of the most commonly used packages and features. It's designed to help you get started with your Flutter project quickly and easily.
- Router for navigation. It's used to manage the routes and navigation.
- Service Locator for dependency injection. It's used to manage the services and repositories.
- Provider Store a MultiBlocProvider that wraps the entire app for state management of the UI.
- Shared Preferences Service for local storage. It's used to manage the local storage.
- Configuration Service A internal service for managing the build configuration. It's used to manage the environment variables.
- Theme Service for managing the app theme.
- Internationalization (i10n) support.
- Logger Custom logger for debugging (Also observes the blocs).
- Device Info Class for getting the device info per platform.
- Flavors configuration for environments: development, staging and production. (IOS, Android and Web)
- Husky for pre-commit and pre-push hooks. (Lint, Format, Tests)
- App Bootstrap function for initializing the app that applies to all flavors.
- Build Runner using json_serializable and freezed for generating the models and services.
- Flutter Lint for code analysis.
- flutter
- flutter_web_plugins
- flutter_localizations
- cupertino_icons
- json_annotation
- freezed_annotation
- get_it
- bloc
- bloc_concurrency
- flutter_bloc
- flutter_svg
- equatable
- shared_preferences
- provider
- flutter_localized_locales
- go_router
- intl
- device_info_plus
- package_info_plus
- flutter_test
- bloc_test
- flutter_lints
- husky
- build_runner
- freezed
- json_serializable
- mocktail
-
Clone this repository:
git clone
-
Install dependencies:
flutter pub get
-
Active the husky hooks: (Needs to be done only once after cloning)
dart run husky install
-
Execute the build runner to generate the models and services:
flutter pub run build_runner build --delete-conflicting-outputs
You can run the app in two ways:
The build runner is executed automatically when you make a hot restart by a preLaunchTask in the launch.json file. (Only for development)
The three launch configurations are:
- Development
- Staging
- Production
You can change the configuration in the launch.json file.
For the auto generate files, you must run the build runner manually You should run this anytime you make a change in the models or services.
flutter pub run build_runner build --delete-conflicting-outputs
flutter run --flavor development --target lib/main_development.dart
flutter run --flavor staging --target lib/main_staging.dart
flutter run --flavor production --target lib/main_production.dart --release
To run the unit tests use the following command:
$ flutter test --coverage --test-randomize-ordering-seed random
To view the generated coverage report you can use lcov.
# Generate Coverage Report
$ genhtml coverage/lcov.info -o coverage/
# Open Coverage Report
$ open coverage/index.html
This project relies on flutter_localizations and follows the official internationalization guide for Flutter.
- To add a new localizable string, open the
app_en.arb
file atlib/l10n/arb/app_en.arb
.
{
"@@locale": "en",
"appName": "Template App",
"@appName": {
"description": "App Name"
}
}
- Then add a new key/value and description
{
"@@locale": "en",
"appName": "Template App",
"@appName": {
"description": "App Name"
}
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World"
}
}
- Use the new string
import 'package:flutter_app_empty_template/l10n/l10n.dart';
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
return Text(l10n.helloWorld);
}
Update the CFBundleLocalizations
array in the Info.plist
at ios/Runner/Info.plist
to include the new locale. (IOS)
...
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...
- For each supported locale, add a new ARB file in
lib/l10n/arb
.
βββ l10n
β βββ arb
β β βββ app_en.arb
β β βββ app_es.arb
- Add the translated strings to each
.arb
file:
app_en.arb
{
"@@locale": "en",
"appName": "Template App",
"@appName": {
"description": "App Name"
}
}
app_es.arb
{
"@@locale": "es",
"appName": "Plantilla de App",
"@appName": {
"description": "Nombre de la App"
}
}
This project is licensed under the MIT License - see the LICENSE file for details.