activout_firebase_options_selector 1.0.0 copy "activout_firebase_options_selector: ^1.0.0" to clipboard
activout_firebase_options_selector: ^1.0.0 copied to clipboard

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!

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 #

  1. Create separate Firebase projects for production, test and development (or what you prefer).
  2. Generate firebase_options files for each Firebase project with the FlutterFire CLI.
  3. 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;

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?

3
likes
140
pub points
83%
popularity

Publisher

verified publisheractivout.se

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!

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

firebase_core, flutter, shared_preferences

More

Packages that depend on activout_firebase_options_selector