This template uses flutter_bloc as state management and follows uncle bob's clean architecture.
This project contains 3 variants:
- development
- staging
- production
To run the desired variants either use the launch configuration in VSCode/Android Studio or use the following commands:
flutter run -t lib/main-development.dart --flavor development
flutter run -t lib/main-production.dart --flavor production
flutter run -t lib/main-staging.dart --flavor staging
flutter pub run flutter_launcher_icons:main
flutter pub run flutter_native_splash:create
$ flutter pub run build_runner build --delete-conflicting-outputs
or
$ flutter pub run build_runner watch --delete-conflicting-outputs
This project relies on [flutter_localizations][flutter_localizations_link] and flutter_intl and follows the [official internationalization guide for Flutter][internationalization_link].
- To add a new localizable string, open the
intl_en.arb
file atlib/localization/arb/intl_en.arb
.
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
- Then add a new key/value and description
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
},
"helloWorld": "Hello World",
"@helloWorld": {
"description": "Hello World Text"
}
}
- Use the new string
import 'package:meeting_room/localization/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.
<dict>
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
</array>
</dict>
- For each supported locale, add a new ARB file in
lib/localization/arb
.
βββ localization
β βββ arb
β β βββ intl_en.arb
β β βββ intl_ne.arb
- Add the translated strings to each
.arb
file:
app_en.arb
{
"@@locale": "en",
"counterAppBarTitle": "Counter",
"@counterAppBarTitle": {
"description": "Text shown in the AppBar of the Counter Page"
}
}
app_ne.arb
{
"@@locale": "ne",
"counterAppBarTitle": "Contador",
"@counterAppBarTitle": {
"description": "Texto mostrado en la AppBar de la pΓ‘gina del contador"
}
}
- Generate localized strings
flutter pub global activate intl_utils (if not activated previously)
flutter pub global run intl_utils:generate (this is for the first time next time it will be auto generated when we run flutter pub get or just saving pubspec.yaml)
.
βββ bootstrap.dart # bootstrap file that contains bloc observer and dependencies initialization functions
βββ localization #localized strings
β βββ arb
β β βββ intl_en.arb
β βββ generated
β βββ l10n.dart # extension functions to access generated localized strings
βββ main-dev.dart # entrypoint for development app
βββ main-prod.dart # entrypoint for production app
βββ main-uat.dart # entrypoint for uat app
βββ src # source folder (all the project source files goes under this directory)
βββ app # folder contains files that is accessible to all over app
β βββ app.dart # index file that exports presentation/pages
β βββ data # data folder contains all the files those are associated with backend and local database
β β βββ database # database folder contains DAOs and local database tables for respective feature
β β βββ dtos # dtos contains all the files those are used to convert server response into dart class
β β βββ graphql # graphql contains queries and mutations files those are use to communicate GraphQl server
β β βββ mappers # mappers contains extension functions that maps the local database response into entity
β β βββ repository # repository contains the implementation of abstract class in domain/repository
β β βββ source # source contains abstract and implementation files to communicate with server and local database
β βββ domain # domain folder contains all the files that are used to communicate between data and presentation layer
β β βββ entities # entities are used to communicate server/local response into UI layer
β β βββ repository # repository contains all the abstract classes used to communicate with data layer
β β βββ usecases # usecases are used to communicate repository and bloc classes
β βββ presentation # presentation folder contains all the UI and BLOC related files
β βββ blocs # contains all the bloc files
β β βββ app
β β β βββ app_cubit.dart
β β β βββ app_cubit.freezed.dart
β β β βββ app_state.dart
β β βββ locale
β β βββ locale_cubit.dart
β β βββ locale_cubit.freezed.dart
β β βββ locale_state.dart
β βββ pages # contains all the pages of respective feature
β β βββ app.dart
β β βββ splash_page.dart
β βββ widgets # contains widgets that is common on respective feature's pages
β βββ widgets.dart
βββ core # core contains all the helper,utilities,constants, routing etc.
β βββ constants # constants
β β βββ storage_keys.dart
β βββ database # local database class
β β βββ local_database.dart
β β βββ local_database.g.dart
β β βββ test_dao.dart
β β βββ test_dao.g.dart
β βββ di # dependency injections
β β βββ injector.config.dart
β β βββ injector.dart
β β βββ register_modules.dart
β β βββ register_network_module.dart
β βββ errors # app errors and exceptions
β β βββ api_exception.dart
β β βββ api_exception.freezed.dart
β β βββ app_error.dart
β β βββ app_error.freezed.dart
β βββ extensions # extension functions for different class
β β βββ context_extension.dart
β β βββ extensions.dart
β β βββ num_extension.dart
β β βββ string_extension.dart
β β βββ widget_extension.dart
β βββ form # form validation fields
β β βββ field.dart
β β βββ form_mixin.dart
β βββ helpers # helpers
β β βββ assets_helper.dart
β β βββ encryption_helper.dart
β βββ logging # loggers
β β βββ logger.dart
β βββ network # interceptors and connection_checkers
β β βββ auth_interceptor.dart
β β βββ network_info.dart
β βββ routes # routes
β β βββ app_router.dart
β β βββ app_router.gr.dart
β β βββ app_routes.dart
β βββ session # session implementations
β β βββ entity
β β β βββ session_entity.dart
β β β βββ session_entity.g.dart
β β βββ session_service.dart
β βββ themes # themes, colors, typography
β β βββ app_colors.dart
β β βββ app_styles.dart
β β βββ app_theme.dart
β β βββ theme.dart
β βββ typedefs # typedefs
β β βββ typedefs.dart
β βββ usecase # base usecase class
β β βββ usecase.dart
β βββ widgets # widgets those are shared across different features
β βββ app_error_widget.dart
β βββ network_image.dart
β βββ svg_image.dart
β βββ widgets.dart
βββ features # features contains all the features following same architecture as app
βββ auth
β βββ auth.dart
β βββ data
β β βββ database
β β βββ dtos
β β βββ graphql
β β βββ mappers
β β βββ repository
β β βββ source
β βββ domain
β β βββ entities
β β βββ repository
β β βββ usecases
β βββ presentation
β βββ blocs
β βββ pages
β βββ login_page.dart
βββ dashboard
βββ dashboard.dart
βββ data
β βββ database
β β βββ daos
β β βββ tables.dart
β βββ dtos
β β βββ company
β β βββ launch
β βββ graphql
β β βββ mutations.dart
β β βββ queries.dart
β βββ mappers
β β βββ mappers.dart
β βββ repository
β β βββ dashboard_repository_impl.dart
β βββ source
β βββ dashboard_local_source.dart
β βββ dashboard_remote_source.dart
βββ domain
β βββ entities
β βββ repository
β β βββ dashboard_repository.dart
β βββ usecases
βββ presentation
βββ blocs
β βββ company
β βββ launches
β β βββ details
β β βββ latest
β β βββ upcoming
β βββ vehicles
β βββ details
β βββ list
βββ pages
β βββ dashboard_page.dart
βββ widgets
βββ widgets.dart
-
auto_route used for routing
-
get_it used for service locator
-
injectable used for dependency injection with get_it
-
flutter_bloc used for state management
-
flutter_screenutil used to get adaptive sizes
-
freezed used to generate union classes
-
json_serializable used to generate jsonConverter for models
-
equatable used to generate equality for models
-
dartz used for functional programming
-
internet_connection_checker used to check internet connectivity status
-
dio used for http client
-
graphql http client for graph requests
-
gql_dio_link used to add a dio link to graphql client to use features of dio
-
flutter_dotenv used to manage different variables for different environment
-
flutter_secure_storage used to create and store encryption key for hive
-
hive used to manage session of user
-
hive_flutter used with hive to make hive work in flutter
-
logging used for logging
-
device_info_plus used to get information of device
-
path_provider used to get different path from app (documents,downloads etc.)
-
path used for path manipulating
-
drift used for local database
-
sqlite3_flutter_libs used with drift to work with sqlite
-
flutter_native_splash used to create native splash on different platform
-
cached_network_image used to render network images
-
flutter_svg used to render svg images