Flutter image_picker无法与PlatformException一起使用

时间:2019-08-15 15:29:33

标签: android image flutter dart

我正在使用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)

谢谢

0 个答案:

没有答案