activout_firebase_options_selector 0.0.1 activout_firebase_options_selector: ^0.0.1 copied to clipboard
FirebaseOptions selection for easier development
Usr this library from Activout AB to switch between different Firebase projects in your app.
Features #
When you have multiple Firebase projects for production, test and development, use this library to make it easier to switch between environments without building separate apps!
Getting started #
- Create separate Firebase projects for production, test and development (or what you prefer).
- Generate firebase_options files for each Firebase project with the FlutterFire CLI.
- Add this library to your project with
flutter pub add activout_firebase_options_selector
Usage #
See the example
subdirectory for a full example.
In your main.dart file, import all your firebase_options.dart
files generated
by FlutterFire CLI:
import 'package:example/firebase_options_production.dart' as production;
import 'package:example/firebase_options_test.dart' as test;
import 'package:example/firebase_options_development.dart' as development;
Update your main
method to be async
call FirebaseOptionsSelector.initialize()
with await
:
Future<void> main() async {
const productionKey = 'Production';
await FirebaseOptionsSelector.initialize(productionKey, {
productionKey: production.DefaultFirebaseOptions.currentPlatform,
"Test": test.DefaultFirebaseOptions.currentPlatform,
"Development": development.DefaultFirebaseOptions.currentPlatform,
});
runApp(const MyApp());
}
When you create your MaterialApp
, set the builder
property to add a banner to the app when it is not running with
production options:
return MaterialApp(
builder: FirebaseOptionsSelector.materialAppBuilder,
In a secret place, such as triple-tap on your logo, open the Firebase options selector dialog:
onPressed: () async {
await showFirebaseOptionsSelectorDialog(context, "Select environment and restart app");
},
Additional information #
Activout AB is a Swedish Flutter mobile app agency. Maybe we can help your company?