Splittr is a Flutter-based multi-platform application utilizing clean architecture, BLoC for state management, Injectable for dependency injection, and Hive for offline-first caching.
We use the envied package to manage compile-time environment variables with full obfuscated encryption for production keys.
Real environment files are gitignored to prevent leaks. To set up your local environment:
- Copy the example templates in the project root:
cp .env.dev.example .env.dev cp .env.prod.example .env.prod
- Populate the
.env.devand.env.prodfiles with your actual credentials.
Environment variables are unified within a single MultiEnv class using stacked @Envied annotations to cleanly separate development and production profiles:
// lib/core/app_config/env/multi_env.dart
@Envied(path: '.env.dev', name: 'DebugEnv', obfuscate: true)
@Envied(path: '.env.prod', name: 'ProductionEnv', obfuscate: true)
abstract class MultiEnv {
static late final MultiEnv instance;
static void init(Env env) {
instance = switch (env) {
Env.dev => _DebugEnv(),
Env.prod => _ProductionEnv(),
};
}
// Define environment-specific fields below
abstract final String apiBaseUrl;
abstract final String vercelBypassKey;
}Once you update your .env.dev or .env.prod files, run the build runner to compile the environments:
fvm flutter pub run build_runner build --delete-conflicting-outputsEnsure you install the Firebase CLI and FlutterFire CLI before running these commands:
flutterfire configure --platforms=android --android-package-name=com.example.splittr.dev --android-out=android/app/src/dev/google-services.json --out=lib/core/firebase/firebase_options_dev.dartflutterfire configure --platforms=android --android-package-name=com.example.splittr --android-out=android/app/src/prod/google-services.json --out=lib/core/firebase/firebase_options_prod.dartThe app supports target-specific entry points (lib/main_dev.dart and lib/main_prod.dart) along with Flutter build flavors.
Use the predefined configurations in .vscode/launch.json:
- Select Dev to run development.
- Select Prod to run production.
Ensure you have configured run/debug targets:
- Go to Edit Configurations.
- Add a new Flutter run configuration.
- Name it DEV or PROD.
- Set the Dart entrypoint to
lib/main_dev.dart(DEV) orlib/main_prod.dart(PROD). - Set the Build Flavor section to
dev(DEV) orprod(PROD).
We use Mason to generate uniform pages and components.
- Activate Mason CLI globally:
dart pub global activate mason_cli
- Navigate to the mason directory and install the brick registry:
cd mason mason get
- Create a Page:
mason make feature_page -o ../lib/features/ --on-conflict overwrite --feature_name <yourFeatureName>
- Create a Component:
mason make feature_component -o ../lib/features/ --on-conflict overwrite --feature_name <yourFeatureName>
Use the following commands to clean caches or reset dependencies:
# Clean pub cache
fvm flutter pub cache clean
fvm flutter pub cache repair
# Clean build artifacts
fvm flutter clean