Reputation: 83
before the Flutter update today my app ran OK, now get: 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.
Any ideas? E/flutter (29270): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
I am using : import 'package:get_it/get_it.dart';
void main() async {
await di.init();
runApp(MyApp());
}
Where di.init() initialises the bloc
Upvotes: 2
Views: 5074
Reputation: 908
I found the solution online:
Just put this row on the top of the main function:
WidgetsFlutterBinding.ensureInitialized();
Upvotes: 7