Posts

First Exception in Flutter: FlutterError (ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.

Image
  Here is the first exception that I got when I was running a Flutter App. FlutterError (ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized. If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first. If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.) Fix: Add the below code line just after main: WidgetsFlutterBinding.ensureInitialized(); Voila! the problem is fixed! Just like in the screenshot: