A codebase for Flutter projects uses Riverpod for the state management, adopts Clean Architecture.
- Riverpod: State management library
- Hooks: Less code, more compicated 🥲🥲
- Dio: For communicating with APIs
- And more,... check out the
pubspec.yamlfile
- Change the application id:
- Android: Change the package name
- iOS: Change the bundle id:
- Create AppID on Apple Developer Portal.
- Create profiles, certificates for each build type (recommend using
Fastlane match)
- Set up Firebase (optional): Add Firebase to your Flutter app
Run below command line to generate the AppLocalizations file.
flutter gen-l10nManage string constants:
- Put the string in the corresponding .arb file (e.g localization/app_en.arb).
- Use
$stringsto get the string at everywhere in the app.
@riverpodto generate a auto dispose provider.@Riverpod(keepAlive: true)to generate a always keep alive provider.- Run below command line to generate code:
dart run build_runner build --delete-conflicting-outputspart 'song_repository_impl.g.dart';
class SongRepositoryImpl with DioBroker implements SongRepository {
SongRepositoryImpl(this._dio);
final SaavnDio _dio;
}
@riverpod
SongRepository songRepository(SongRepositoryRef ref) {
return SongRepositoryImpl(ref.read(saavnDioProvider));
}part 'app_settings_notifier.g.dart';
@Riverpod(keepAlive: true)
class AppSettingsNotifier extends _$AppSettingsNotifier {
@override
AppSettings build() {
return AppSettings();
}
}part 'authentication_notifier.g.dart';
@riverpod
class AuthenticationNotifier extends _$AuthenticationNotifier {
@override
FutureOr<dynamic> build() async {
return null;
}
}- Check out reference
- Add flutter_flavorizr dependency.
- Create your flavors config at the end of
pubspec.yamlfile. Example:
flavorizr:
flavors:
dev:
app:
name: "Wherever Dev"
android:
applicationId: "asia.executionlab.wherever_dev"
ios:
bundleId: "asia.executionlab.wherever-dev"
firebase:
config: ".firebase/dev/GoogleService-Info.plist"
stg:
app:
name: "Wherever Stg"
android:
applicationId: "asia.executionlab.wherever_stg"
ios:
bundleId: "asia.executionlab.wherever-stg"
firebase:
config: ".firebase/stg/GoogleService-Info.plist"
prod:
app:
name: "Wherever"
android:
applicationId: "asia.executionlab.wherever_prod"
ios:
bundleId: "asia.executionlab.wherever-prod"
firebase:
config: ".firebase/prod/GoogleService-Info.plist"
- Run flutter_flavorizr:
flutter pub run flutter_flavorizr- Add newly created flavors to Podfile. Example:
project 'Runner', {
'Debug-dev' => :debug,
'Profile-dev' => :release,
'Release-dev' => :release,
'Debug-stg' => :debug,
'Profile-stg' => :release,
'Release-stg' => :release,
'Debug-prod' => :debug,
'Profile-prod' => :release,
'Release-prod' => :release,
}- Delete 2 files:
Podfile.lock,Runner.xcworkspaceand folderPods - Clean Pod cache:
pod cache clean --all
pod deintegrate
pod setup
pod installNote using
arch x86-64 pod installif you are using Apple Silicon chip.
- Flutter Riverpod 2.0: The Ultimate Guide
- Riverpod Data Caching and Providers Lifecycle: Full Guide
- Internationalizing Flutter apps
If you have any problems please contact @xuanbach