why doesn’t initializeApp() work? do i need another package? I get this error : The method ‘initializeApp’ isn’t defined for the type ‘FirebaseApp’
import 'package:firebase_core/firebase_core.dart';
void main(){
Firebase.initializeApp();
FirebaseApp.initializeApp();
...
3
Answers
FirebaseApp.initializeApp() can't be used in the main.dart, it's for MainActivity and you need these packages
In MainActivity
In pubspec.yaml
There’s nothing in the documentation that says you should call a method initializeApp on FirebaseApp. The method really doesn’t exist as the error message says.
You just get a FirebaseApp object back from
Firebase.initializeApp()
.See:
I think if you are using one of the latest firebase packages you need to use the new Firebase CLI way of configuring. Check this out https://firebase.flutter.dev/docs/cli/. Overall it’s the installation process of FlutterFire across all supported platforms.
You can also follow through this answer https://stackoverflow.com/a/73774075/10698100