Flutter 添加高德地图启动有警告binary messenger before `runApp()` has been

添加高德地图之后,发现启动时有警告信息

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: 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.

解决办法是在flutter的main里面添加

WidgetsFlutterBinding.ensureInitialized();

这段代码就行,代码最高添加在main()函数的最上面,起码要放在高德地图初始化方法的前面

你可能感兴趣的:(Flutter)