图像选择器retrieveLostData()引发PlatformException

时间:2019-08-10 10:27:16

标签: flutter dart

由于我的android设备在用相机拍摄图像时经常崩溃,因此我试图在flutter应用程序中使用retrieveLostData()函数。我已经将retrieveLostData()函数连接到启动检查中,这样我就可以获取图像并根据需要对其进行处理,但是,每当我调用该函数时,都会引发如下PlatformException错误:

[ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, java.lang.Integer cannot be cast to java.lang.Double, null) E/flutter (17053): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7) E/flutter (17053): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33) E/flutter (17053): <asynchronous suspension> E/flutter (17053): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:344:48) E/flutter (17053): <asynchronous suspension> E/flutter (17053): #3 ImagePicker.retrieveLostData (package:image_picker/image_picker.dart:107:24) E/flutter (17053): <asynchronous suspension>

我用于该函数的代码是pub.dev上image_picker插件页面的直接副本,如下所示:

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

图像选择器已更新为最新版本image_picker 0.6.1 + 2。关于它为什么不断抛出此异常的任何想法?我真的需要使它正常工作,因为我的应用程序根本无法交付,拍照时经常崩溃。

0 个答案:

没有答案