Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 在Dart的主线程中强制执行_Flutter_Dart - Fatal编程技术网

Flutter 在Dart的主线程中强制执行

Flutter 在Dart的主线程中强制执行,flutter,dart,Flutter,Dart,在我的Dart程序中,我使用相机: ... final File imageProduct = await ImagePicker.pickImage(source: ImageSource.camera, maxHeight: 1024, maxWidth: 1024); ... 在以前的版本中,它工作得很好,现在经过颤振升级(v1.7.8+hotfix.3)后,相机界面显示,我可以拍照,之后我得到错误: W/Binder ( 7331): Caught a RuntimeExc

在我的Dart程序中,我使用相机:

...    
final File imageProduct =  await ImagePicker.pickImage(source: ImageSource.camera, maxHeight: 1024, maxWidth: 1024);
...
在以前的版本中,它工作得很好,现在经过颤振升级(v1.7.8+hotfix.3)后,相机界面显示,我可以拍照,之后我得到错误:

W/Binder  ( 7331): Caught a RuntimeException from the binder stub implementation.
W/Binder  ( 7331): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Binder:7331_4
在flatter中,异步函数是在主线程中执行的,所以我真的不明白会出现什么问题。 我找不到在主线程中强制执行的显式方法

解决办法是什么

谢谢

  • 将颤振通道更改为dev(颤振通道dev)。(您可以省略此步骤)
  • 运行颤振升级
  • 将ImagePicker的版本更改为最新版本0.6.3+1
  • 运行项目

  • 问题已解决。

    请参阅,谢谢,这只是版本问题…此解决方案有效,imagepicker的版本升级解决了问题。对我来说,它只需要第3步和重新加载项目。无需颤振升级。