【错误记录】Flutter 插件报错 ( Methods marked with @UiThread must be executed on the main thread. | 更新最新 SDK )(一)

简介: 【错误记录】Flutter 插件报错 ( Methods marked with @UiThread must be executed on the main thread. | 更新最新 SDK )(一)

文章目录

一、报错信息

二、问题分析

三、解决方案





一、报错信息


在 Flutter 中使用 image_picker 插件时 , 如 【Flutter】Flutter 拍照示例 ( 拍照源码示例 ) 中选择照片后 , 报如下错误 :


W/Binder  (30392): Caught a RuntimeException from the binder stub implementation.
W/Binder  (30392): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: Binder:30392_2
W/Binder  (30392):  at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:992)
W/Binder  (30392):  at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(FlutterJNI.java:779)
W/Binder  (30392):  at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:144)
W/Binder  (30392):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:238)
W/Binder  (30392):  at io.flutter.plugins.imagepicker.ImagePickerDelegate.finishWithSuccess(ImagePickerDelegate.java:540)
W/Binder  (30392):  at io.flutter.plugins.imagepicker.ImagePickerDelegate.handleImageResult(ImagePickerDelegate.java:505)
W/Binder  (30392):  at io.flutter.plugins.imagepicker.ImagePickerDelegate.access$000(ImagePickerDelegate.java:66)
W/Binder  (30392):  at io.flutter.plugins.imagepicker.ImagePickerDelegate$4.onPathReady(ImagePickerDelegate.java:470)
W/Binder  (30392):  at io.flutter.plugins.imagepicker.ImagePickerDelegate$3$1.onScanCompleted(ImagePickerDelegate.java:160)
W/Binder  (30392):  at android.media.MediaScannerConnection$ClientProxy.onScanCompleted(MediaScannerConnection.java:204)
W/Binder  (30392):  at android.media.MediaScannerConnection$1.scanCompleted(MediaScannerConnection.java:53)
W/Binder  (30392):  at android.media.IMediaScannerListener$Stub.onTransact(IMediaScannerListener.java:61)
W/Binder  (30392):  at android.os.Binder.execTransact(Binder.java:731)


image.png






二、问题分析


在 image_picker 的主页 , 已经对上述问题作出了说明 , 使用 image_picker 插件选择数据时 , 有时出现图像丢失的情况 , 此时使用 retrieveLostData 获取丢失的图像 ;


代码示例 :


Future<void> retrieveLostData() async {
  final LostData response =
      await picker.getLostData();
  if (response.isEmpty) {
    return;
  }
  if (response.file != null) {
    setState(() {
      if (response.type == RetrieveType.video) {
        _handleVideo(response.file);
      } else {
        _handleImage(response.file);
      }
    });
  } else {
    _handleError(response.exception);
  }
}



还有一个问题就是可能使用了过时的 Flutter 插件 ;






目录
相关文章
|
1月前
Flutter更改主题颜色报错:type ‘Color‘ is not a subtype of type ‘MaterialColor‘
Flutter更改主题颜色报错:type ‘Color‘ is not a subtype of type ‘MaterialColor‘
29 4
|
30天前
|
缓存 Dart 开发工具
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
36 3
|
1月前
|
Dart 开发工具 Android开发
Android Studio导入Flutter项目提示Dart SDK is not configured
Android Studio导入Flutter项目提示Dart SDK is not configured
65 4
|
30天前
|
开发工具 图形学 Android开发
Unity与安卓丨unity报错:SDK Tools version 0.0 < 26.1.1
Unity与安卓丨unity报错:SDK Tools version 0.0 < 26.1.1
|
30天前
|
开发工具 iOS开发
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
80 2
|
1月前
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
65 3
|
1月前
|
Dart
Flutter使用Scaffold报错。
Flutter使用Scaffold报错。
30 3
|
30天前
|
iOS开发
解决Flutter运行IOS报错:Podfile is out of date
解决Flutter运行IOS报错:Podfile is out of date
33 1
|
1月前
|
开发工具 Android开发
Flutter: Android SDK not found at this location,Android Studio not found at xxx
Flutter: Android SDK not found at this location,Android Studio not found at xxx
104 2
|
18天前
|
开发工具 iOS开发 容器
【Azure Blob】关闭Blob 匿名访问,iOS Objective-C SDK连接Storage Account报错
【Azure Blob】关闭Blob 匿名访问,iOS Objective-C SDK连接Storage Account报错

热门文章

最新文章