0 purchases
activout firebase options selector
Use 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.
Initialize this library in your main.dart according to the instructions below. It will call Firebase.initializeApp() for you!
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;
copied to clipboard
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());
}
copied to clipboard
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,
copied to clipboard
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");
},
copied to clipboard
Additional information #
Activout AB is a Swedish Flutter mobile app agency. Maybe we can help your company?
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.