am getting this error. Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)
I have updated all firebase packages in .yaml, i still have this error
E/flutter (11230): [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 (11230): #0 FirebaseCoreHostApi.optionsFromResource (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:242:7)
E/flutter (11230): <asynchronous suspension>
E/flutter (11230): #1 MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:89:25)
E/flutter (11230): <asynchronous suspension>
E/flutter (11230): #2 Firebase.initializeApp (package:firebase_core/src/firebase.dart:40:31)
E/flutter (11230): <asynchronous suspension>
E/flutter (11230): #3 main (package:mossbets/main.dart:22:3)
E/flutter (11230): <asynchronous suspension>
E/flutter (11230):
Let me also add i have made the call to initialize firebase. Once i remove the initialisation the app works fine but without firebase
CodePudding user response:
add these two lines to your main.dart main function
void main() async{
WidgetsFlutterBinding.ensureInitialized();
// initializing the firebase app
await Firebase.initializeApp();
runApp(MyApp());
}
CodePudding user response:
This is probably caused by the new changes with Firebase CLI with firebase options. So to solve this do add :
in your terminal
$ flutterfire configure
then in your main
// Import the generated file
import 'firebase_options.dart';
...
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
...
You probably going to be asked to authenticate your firebase account so you' ll run this in your terminal
dart pub global activate flutterfire_cli
this article will help you...start from step 4 Article