Flutter: Binding has not yet been initialized

1,484

I found the solution for this error in Flutter version >= 3.0:

  1. Add this line to your main():

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      DartPluginRegistrant.ensureInitialized(); //<----FIX THE PROBLEM
      //..
    }
    
Share:
1,484
MedCh
Author by

MedCh

Updated on January 04, 2023

Comments

  • MedCh
    MedCh over 1 year

    After upgrading FLutter to 3.0.0 I got this error when using compute isolate, knowing that I have initialized in main.dart:

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
    
    • Hardik Mehta
      Hardik Mehta almost 2 years
      try flutter clean. flutter pub update then try to run it
    • Javier C.
      Javier C. almost 2 years
      i have the same problem
  • MedCh
    MedCh almost 2 years
    no effect => it's not a future
  • Javier C.
    Javier C. almost 2 years
    for me is not working
  • Xdg
    Xdg over 1 year
    DartPluginRegistrant.ensureInitialized() NOT fixes the problem.