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

discontinued
outdated

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 #

  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. 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?

3
likes
0
points
77
downloads

Publisher

verified publisheractivout.se

Weekly Downloads

FirebaseOptions selection for easier development

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

firebase_core, flutter, shared_preferences

More

Packages that depend on activout_firebase_options_selector