Baboo Kumar
Baboo Kumar

Reputation: 77

Unhandled Exception: Binding has not yet been initialized

i am facing this error for 3 days, i have just used firebase db for authentication, and i don't know how to solve it enter image description here

Upvotes: 5

Views: 6556

Answers (3)

Pritam Kininge
Pritam Kininge

Reputation: 41

You need to initialize the widget rendering or binding process before the asynchronous call

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

Upvotes: 2

Hardik Mehta
Hardik Mehta

Reputation: 2425

As per their error, answer is contained inside:

enter image description here

Add this WidgetsFlutterBinding.ensureInitialized(); before runApp(const MyApp()); inside main()

Upvotes: 14

Thanula
Thanula

Reputation: 81

Try this...

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();
  runApp(const MyApp());
}

Upvotes: 7

Related Questions