Extended of Safer VPN Docs
  • πŸ‘‹Welcome to A Safer VPN Product
  • App Guides
    • πŸ”‘Configure KeyStore Android
    • πŸ“ΆConfigure Firebase
    • πŸ“ͺChange app name
    • ℹ️Change Icon
    • πŸ“ŽChange package name
    • βœ’οΈChange Colors
    • πŸ”°Change admob
    • πŸ”Configure WireGuard Apple
  • Admin Panel
    • πŸ› οΈAdmin Panel
      • πŸ“Admin Panel Installation
  • Subscription
    • πŸ› οΈSubscription Feature
      • πŸ“iOS Product Setup
      • ↗️Google Play Product Setup
  • πŸ‘οΈβ€πŸ—¨οΈApp Config
Powered by GitBook
On this page
  1. App Guides

Configure Firebase

PreviousConfigure KeyStore AndroidNextChange app name

Initializing FlutterFire

⚑ ️FlutterFire now supports initialization directly from Dart! ⚑️

Before any of the Firebase services can be used, FlutterFire needs to be initialized (you can think of this process as FlutterFire "bootstrapping" itself). The initialization step is asynchronous, meaning you'll need to prevent any FlutterFire related usage until the initialization is completed.

Using the FlutterFire CLI

INFO

The FlutterFire CLI depends on the . If you haven't installed it yet, you can learn more about Firebase CLI in the .

To initialize FlutterFire, call the method on the class. The method accepts your Firebase project application configuration, which can be obtained for all supported platforms by using the FlutterFire CLI:

# Install the CLI if not already done sodart pub global activate flutterfire_cli# Run the `configure` command, select a Firebase project and platformsflutterfire configureCopy

Once configured, a firebase_options.dart file will be generated for you containing all the options required for initialization. Additionally, if your Flutter app supports Android then the will automatically be applied for you.

Learn more about the FlutterFire CLI in the .

NOTE

If you add support for a new platform in your Flutter app (e.g. adding Android when your app previously did not support Android), or if you introduce new Firebase services into your app (e.g. adding firebase_database) then you should reconfigure Firebase for your application again via the CLI (flutterfire configure).

Initialization

Next the generated options need to be provided to the method. Since this is an asynchronous operation, the main function can be modified to ensure initialization is complete before running the application.

First import the firebase_core plugin and generated firebase_options.dart file:

lib/main.dartimport 'package:firebase_core/firebase_core.dart';import 'firebase_options.dart';Copy

Next, within the main function, ensure WidgetsFlutterBinding is initialized and then initialize Firebase:

lib/main.dartvoid main() async {WidgetsFlutterBinding.ensureInitialized();await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform,);runApp(MyApp());}Copy

The DefaultFirebaseOptions.currentPlatform is imported from our generated firebase_options.dart file.

Once initialized, you're ready to start using FlutterFire!

πŸ“Ά
Firebase CLI
documentation
initializeApp
Firebase
Android Google Services Gradle plugin
documentation
initializeApp