flutter - 在 Dart 的主线程中强制执行
问题描述
在我的 Dart 程序中,我使用的是相机:
...
final File imageProduct = await ImagePicker.pickImage(source: ImageSource.camera, maxHeight: 1024, maxWidth: 1024);
...
之前的版本很好用,现在Flutter升级(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
在 Flutter 中,异步函数在主线程中执行,所以我真的不明白可能是什么问题。我找不到在主线程中强制执行的明确方法。
可能是什么解决方案。
谢谢。
解决方案
- 将颤振频道更改为开发(颤振频道开发)。(你可以省略这一步)
- 运行颤振升级
- 将 ImagePicker 的版本更改为最新的 0.6.3+1。
- 运行项目
问题解决了。
推荐阅读
- c# - 将 .bmp 作为 .png 保存到 MemoryStream 时出现 ExternalException
- php - 将自定义变体字段数据添加到 CSV 订单导出 - WooCommerce
- java - 在 Freemarker 中为 Spring Boot 2 提供自定义 TemplateMethodModels
- javascript - Jest 如何将 babel.rc 交给 babel-jest?
- python - 将卷积运算应用于图像 - PyTorch
- mqtt - 2 方式 Secured Mosquitto MQTT 错误
- php - PHP 电子邮件清理过滤器
- node.js - Docker 中的 NodeJS 看不到连接
- c# - 是否有任何属性可以选择 ListView 项目设计时间
- css - 如何在css中用一种颜色绘制半对角线,用另一种颜色绘制另一半对角线