So, I wanted to include firebase into my Flutter App, it works fine for android but when I start it on my ios emulator it will always give me this error
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized. Usually this means you've attempted to use a Firebase service before calling
Firebase.initializeApp
. View the documentation for more information: https://firebase.flutter.dev/docs/overview#initialization
I have the google-service file in the right directory and I followed the tutorial and edited my main() to:
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const MyApp());
}
Has anybody the same problem with IOS or did I do anything wrong?
CodePudding user response:
So for everybody else getting this error I figured it out myself, for IOS, the line
Firebase.initializeApp()
it needs an option:
Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform)
for that follow the instructions on this link:
https://firebase.flutter.dev/docs/cli
hope that helps anyone