Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type: dynamic Undefined name 'DefaultFirebaseOptions'. Try correcting the name to one that is defined, or defining the name

This is my initial_bindings.dart. I am trying to integrate my app to firebase and I get this error everytime I try to run it through an emulator.

import 'package:grabbit_v6/data/apiClient/api_client.dart';
import 'package:firebase_core/firebase_core.dart';
import '../../firebase_options.dart';

class InitialBindings extends Bindings {
  @override
  void dependencies() async {
    Get.put(PrefUtils());
    Get.put(ApiClient());
    Connectivity connectivity = Connectivity();
    Get.put(NetworkInfo(
        // ignore: todo
        connectivity)); //TODO : run command "flutterfire configure" to generate firebase_options file
    await Firebase.initializeApp(
      options: DefaultFirebaseOptions.currentPlatform,
    );
  }
}
like image 562
John Michael Tan Avatar asked Dec 02 '25 17:12

John Michael Tan


2 Answers

Replace the values from firebase

await Firebase.initializeApp(
    options: FirebaseOptions(
      apiKey: "Api key here",
      appId: "App id here",
      messagingSenderId: "Messaging sender id here",
      projectId: "project id here",
    ),
  );
like image 194
Kaushik Chandru Avatar answered Dec 05 '25 07:12

Kaushik Chandru


Checkout FlutterFire Getting Started documentation

Steps:

  1. Install flutter fire using command dart pub global activate flutterfire_cli
  2. Make sure flutter fire cli is added in your system's path
  3. Run the command flutterfire configure

This command will list out all your firebase projects & allow you to choose the project you want to use. Once this command completes successfully, it should generate a file 'firebase_options.dart' from which you can import DefaultFirebaseOptions.currentPlatform

like image 43
Ganapat Avatar answered Dec 05 '25 07:12

Ganapat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!