[英]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.在今天的 Flutter 更新之前,我的应用程序运行正常,现在得到:如果您正在运行一个应用程序并且需要在
runApp()
之前访问二进制信使(例如,在插件初始化期间),那么您需要显式调用WidgetsFlutterBinding.ensureInitialized()
。
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.
E/flutter (29270): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] 未处理的异常:在绑定初始化之前访问了 ServicesBinding.defaultBinaryMessenger。
I am using : import 'package:get_it/get_it.dart';我正在使用: import 'package:get_it/get_it.dart';
void main() async {
await di.init();
runApp(MyApp());
}
Where di.init() initialises the bloc di.init() 在哪里初始化块
i found an solution online:我在网上找到了一个解决方案:
just put this row to the top of the main function:只需将此行放在主函数的顶部:
WidgetsFlutterBinding.ensureInitialized();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.