0

I am using:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
 
  runApp(...);
}

On running the app on Android, I get the following error:

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(firebase_core, Can't create handler inside thread Thread[pool-3-thread-1,5,main] that has not called Looper.prepare(), null, null)

I'm using firebase_in_app_messaging: ^0.6.0+6. The above code works on removing this package.

If I remove await keyword, the code runs successfully, but is this a bug or am I doing it incorrectly?

iDecode
  • 22,623
  • 19
  • 99
  • 186

1 Answers1

0

What if you add Future< void> ?

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
   await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform);
runApp(...); ,}