Search code examples
iosflutterdartios-frameworks

Image Picker package not working in iOS as framwork


I m using image_picker in my flutter module.

Its working fine in andorid as app & aar (module) and working fine in iOS as app. BUT NOT AS FRAMEWORK

My code is below

XFile? result = await ImagePicker().pickImage(source: ImageSource.gallery).catchError((er){
      debugPrint('Error while picking the image :: $er');
    });

And generating iOS framework with flutter build ios-framework

and I'm getting the following error

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      ImagePickerApi.pickImage (package:image_picker_ios/src/messages.g.dart:126)
<asynchronous suspension>
#1      ImagePickerIOS.getImage (package:image_picker_ios/image_picker_ios.dart:168)
<asynchronous suspension>
#2      MindMapNativeHelper.pickImage (package:mind_map_module/platformHelpers/mindMapNativeHelper.dart:276)
<asynchronous suspension>

I added the required permissions in both android and iOS for Camera, Photos & Microphone.


Solution

  • I added the below line and it worked

    GeneratedPluginRegistrant.register(with: self.flutterEngine);