Authentication flutter app example for Android and iOS.
Implementation of a clean architecture with riverpod and 180 tests (+95% code coverage without UI, provider & go_router).
The objective of this project is to make the best use of good practices and to provide a template for a new project.
- β¨ Demo
- π Getting Started
- βΉοΈ Informations
- π» Commande line
- π¦ Package used
- π Translations
- π Deploying the app
- π Possibility of improvement
- π¦ Useful package
- 𧱠Project structure
- π Helped me
This project contains 3 flavors:
- development
- staging
- production
Editing .env.dev
, .env.stg
, .env.prod
files and add .env*
to .gitignore
file.
To run the desired flavor either use the launch configuration in VSCode/Android Studio or use the following commands:
# Run Development
$ flutter run --flavor development --target lib/main_development.dart
# Run Staging
$ flutter run --flavor staging --target lib/main_staging.dart
# Run Production
$ flutter run --flavor production --target lib/main_production.dart
- Implementation of
FakeLoginRemoteDataSourceImpl
, UsingLoginRemoteDataSourceImpl
to implement real login - Added a listener in the
app.dart
file to display a global failure snackbar - Added a listener in the
app.dart
file to display a global loader overlay with loader_overlay - Implementation of
privacy_provider.dart
to manage user's privacy status - Saving user in phone, Using local_auth to re-login with biometrics
Build runner for freezed and json_serializable
flutter pub run build_runner build --delete-conflicting-outputs
flutter pub run flutter_native_splash:create --path=flutter_native_splash.yaml
flutter pub run flutter_native_splash:remove
Generation of icons for the different flavors for Android and iOS
# Production
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-production.yaml
# Staging
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-staging.yaml
# Development
flutter pub run flutter_launcher_icons:main -f flutter_launcher_icons-development.yaml
Test coverage More detail here
sh scripts/import_files_coverage.sh template
sh scripts/create_clean_lcov_and_generate_html.sh true
- Riverpod implementation for state-management
- Using go_router and
ChangeNotifier
to handle redirects - Wiredash implementation in
app.dart
file to manage feedbacks - Implemented sentry_flutter in
main_prepod.dart
andmain_prod.dart
to capture errors & logger - Managing different environments with flutter_dotenv. Editing the
.env.dev
,.env.stg
,.env.prod
files and add.env*
to.gitignore
file - Using intl to handle multiple languages (
lib/core/locales
) - Using local_auth to re-login with biometrics
- Using fvm to manage flutter versions with sidekick
- Using mocktail for tests
This project relies on [flutter_localizations][https://api.flutter.dev/flutter/flutter_localizations/flutter_localizations-library.html] with Flutter Intl.
- To add a new localizable string, open the
intl_en.arb
and all other.arb
file atlib/core/lcoales/l10n/
.
{
"helloWorld": "Hello World!",
"@helloWorld": {
"description": "The conventional newborn programmer greeting"
}
}
- Use the new string
import 'lib/core/locales/generated/l10n.dart';
// If you don't have `context` to pass
@override
Widget build(BuildContext context) {
return Text(S.current.helloWorld);
}
// With context
@override
Widget build(BuildContext context) {
return Text(S.of(context).helloWorld);
}
Update the CFBundleLocalizations
array in the Info.plist
at ios/Runner/Info.plist
to include the new locale.
...
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>es</string>
</array>
...
For each supported locale, add a new ARB file in lib/core/locales/l10n
.
βββ core
β βββlocales
β β βββ l10n
β β β βββ app_en.arb
β β β βββ app_es.arb
- Code Signin Assets
- π Apple Certificate
- public key (download from the developer.apple.com console)
- private key (.p12)
- π€ Android Keystore
key.properties
file -> to store at:app/android/key.properties
android_key.keystore
file -> to store at:app/android/app/android_key.keystore
- π Apple Certificate
In pubspec.yaml
:
version: 0.0.1+1 # {version}+{build} Bump version following semantic version rules, and bump build ALWAYS (for each new release)
commit and push to master
branch
commit and push tag v{version} (v0.0.1)
to master
branch
- π iOS :
flutter build ios --flavor production --target lib/main_prod.dart --release
- π€ Android :
flutter build appbundl --flavor production --target lib/main_prod.dart --release
Upload the build to App Store Connect using the Transporter App
Go to the App Store Connect console: https://appstoreconnect.apple.com/apps/
- β³ Wait for the build to be available for testing
- π Submit for review
- π§ͺ Submit to Internal or External testers
- π Create a new version
- π¦ Select the latest build
- π Submit for review
- π² Submit to users
Go to Google Play console: https://play.google.com/console/u/0/developers/
- π Create a Release
- π¦ Uploader the build
- π§ͺ Submit to testers
- π Create a Release
- π¦ Uploader the build
- π² Submit to users
- Replace flutter_dotenv package to make key hacking harder. Instead, use the ENVied package and enable obfuscation.
- Added accessibility with Semantics
- Implementation widget test, provider test, go_router test and integration tests
lib/
ββ core/
β ββ credentials.dart
β ββ constants/
β ββ enums/
β ββ impl/
β β ββ api/
β β ββ local_auth/
β β ββ logger/
β β ββ network_info/
β β ββ package_info/
β β ββ picker_file/
β β ββ secure_storage/
β β ββ share_file/
β ββ locales/
β ββ router/
β ββ utils/
β β ββ errors/
β β ββ extensions/
β β ββ platform/
β β ββ usecases/
β β ββ utils.dart
β β ββ utils_ui.dart
β β ββ utils_validator.dart
ββ features/
β ββ commons/
β β ββ pages/
β β ββ providers/
β β ββ widgets/
β ββ feature1/
β β ββ data/
β β β ββ datasources/
β β β ββ models/
β β β ββ repositories/
β β ββ domain/
β β β ββ entities/
β β β ββ repositories/
β β β ββ usecases/
β β ββ presentation/
β β β ββ pages/
β β β ββ provider/
β β β ββ widgets/
ββ ui/
β ββ assets/
β ββ colors/
β ββ icons/
β ββ layout/
β ββ spacing/
β ββ themes/
β ββ typography/
β ββ widgets/
ββ app.dart
ββ main_dev.dart
ββ main_preprod.dart
ββ main_prod.dart
test/
The links that helped me create this template
- Dev CafΓ©
- Reso Coder
- Code with Andrea
- Flutter Mapp
- Udemey : Flutter & Dart - The Complete Guide (2022 Edition)
- Flavors Android & iOS
- https://github.com/rrousselGit/riverpod
- https://github.com/lucavenir/go_router_riverpod
- https://github.com/flutter/packages/tree/main/packages/go_router
- https://brickhub.dev/bricks/app_ui/0.0.4
- https://brickhub.dev/bricks/clean_architecture_folders_lib/0.1.0+2
- https://github.com/gskinnerTeam/flutter-wonderous-app
- https://betterprogramming.pub/flutter-unit-testing-the-beginners-guide-35105164722e#22c2