skip to Main Content

I am trying to use the image picker dependency, but I am running into a. a bit of a problem.
Here is the function I created for the image picker:

 pickImage(ImageSource source)async{
    final ImagePicker imagePicker = ImagePicker();

   XFile? file =await imagePicker.pickImage(source: source);
   if(file != null){
     return file.readAsBytes();
   }else{
     print('no image selected');
   }
  }

this was created in a class called _authController. I then created another function for it to pick from the gallery specifically

Uint8List? _image;
  final AuthController _authController = AuthController();

  gallarypick()async{
   Uint8List im = await _authController.pickImage(ImageSource.gallery);
   setState(() {
     _image = im;
   });
  }

when i called the function, it gave me this error

W/DynamiteModule( 3685): Local module descriptor class for com.google.android.gms.providerinstaller.dynamite not found.
I/DynamiteModule( 3685): Considering local module com.google.android.gms.providerinstaller.dynamite:0 and remote module com.google.android.gms.providerinstaller.dynamite:0
W/ProviderInstaller( 3685): Failed to load providerinstaller module: No acceptable module com.google.android.gms.providerinstaller.dynamite found. Local version is 0 and remote version is 0.
W/ConnectivityManager.CallbackHandler( 3685): callback not found for CALLBACK_AVAILABLE message
D/EGL_emulation( 3685): app_time_stats: avg=163941.78ms min=37.00ms max=654994.19ms count=4
D/EGL_emulation( 3685): app_time_stats: avg=1099.78ms min=894.68ms max=1304.88ms count=2
E/flutter ( 3685): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method pickImage on channel plugins.flutter.io/image_picker)
E/flutter ( 3685): #0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:294:7)
E/flutter ( 3685): <asynchronous suspension>
E/flutter ( 3685): #1      MethodChannelImagePicker.getImageFromSource (package:image_picker_platform_interface/src/method_channel/method_channel_image_picker.dart:209:26)
E/flutter ( 3685): <asynchronous suspension>
E/flutter ( 3685): #2      AuthController.pickImage (package:car_app/controllers/auth_controller.dart:12:17)
E/flutter ( 3685): <asynchronous suspension>
E/flutter ( 3685): #3      _SellerSignUpState.gallarypick (package:car_app/signup%20and%20login/seller%20signup%20and%20login/seller_signup.dart:25:19)
E/flutter ( 3685): <asynchronous suspension>
E/flutter ( 3685): 

I do not understand what is wrong. Help would be very much appreciated

2

Answers


  1. You probably installed the package and tries to execute its code directly, the image_picker package needs to get into native functionalities from the device, so it needs a re-run of your app, not hot restart/reload :

    • stop your app from running
    • run the flutter clean command
    • run the flutter pub get command

    then run your debug app again, and it should work

    Login or Signup to reply.
  2. please add the necessary android permissions like below in android manifest file and let me know if it works

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    

    please refer to the link below which is of same kind.

    https://github.com/flutter/flutter/issues/17545

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search