gpt4 book ai didi

android - Flutter image_picker 不适用于 PlatformException

转载 作者:行者123 更新时间:2023-12-05 00:05:45 27 4
gpt4 key购买 nike

我正在使用 image_picker: ^0.6.1+2 并在单击按钮时调用 getImage() 函数:

File _image;

Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.camera);

setState(() {
_image = image;
});
}

当我点击按钮时总是会出现这个错误。

E/flutter (17542): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.content.res.XmlResourceParser android.content.pm.ProviderInfo.loadXmlMetaData(android.content.pm.PackageManager, java.lang.String)' on a null object reference, null)
E/flutter (17542): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:564:7)
E/flutter (17542): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (17542): <asynchronous suspension>
E/flutter (17542): #2 ImagePicker.pickImage (package:image_picker/image_picker.dart:59:40)
E/flutter (17542): <asynchronous suspension>
E/flutter (17542): #3 _GetLocationPageState.getImage (package:baladity/formulaire_reclamation.dart:102:35)
E/flutter (17542): <asynchronous suspension>
E/flutter (17542): #4 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:635:14)
E/flutter (17542): #5 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:711:32)
E/flutter (17542): #6 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (17542): #7 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
E/flutter (17542): #8 TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:312:7)
E/flutter (17542): #9 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter (17542): #10 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter (17542): #11 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (17542): #12 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (17542): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (17542): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (17542): #15 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (17542): #16 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (17542): #17 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (17542): #18 _invoke1 (dart:ui/hooks.dart:250:10)
E/flutter (17542): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:159:5)

谢谢,

最佳答案

更新 image_pickerflutter clean 的插件,为 Flutter 项目生成新的构建文件。如本 issue thread 所述,这些步骤通常会解决带有 PlatformException 的 image_picker 问题。 .

关于android - Flutter image_picker 不适用于 PlatformException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57512106/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com