I am trying to connect my app to firebase, It ran fine until I changed my main.dart files’s to
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Please help, I am stuck here since 3 days
I’ve tried reconnecting to firebase from scratch twice watching different youtube videos , but still I am unable to connect
The error which I am getting:
E/flutter ( 6526): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
E/flutter ( 6526): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:248:7)
E/flutter ( 6526): <asynchronous suspension>
E/flutter ( 6526): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:107:9)
E/flutter ( 6526): <asynchronous suspension>
E/flutter ( 6526): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:43:31)
E/flutter ( 6526): <asynchronous suspension>
E/flutter ( 6526): #3 main (package:electralink/main.dart:11:3)
E/flutter ( 6526): <asynchronous suspension>
E/flutter ( 6526):
2
Answers
we don’t use "future" main()
try this…
}
use this for init firebase