user2244131
user2244131

Reputation: 83

Flutter Update WidgetsFlutterBinding

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

Answers (1)

Edin
Edin

Reputation: 908

I found the solution online:

Just put this row on the top of the main function:

WidgetsFlutterBinding.ensureInitialized();

Upvotes: 7

Related Questions