image_picker is not working after building flutter apps for Camera Image Picking

76 Views Asked by At
_getFromCamera() async {
  XFile? pickedFile = await ImagePicker().pickImage(
    source: ImageSource.camera,
      maxWidth: 1800,
      maxHeight: 1800,
  );
}

It is working fine for

source: ImageSource.gallery,

but for camera, it is not working

I have tried at first flutter version upgrading, installing

permission_handler

package but not working after building the apps

1

There are 1 best solutions below

0
On

At first, need to add permission in AndroidManifest.xml as follows:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

After that, install permission_handler package.

Then the build will work for both camera and gallery. It will ask for permission and works fine.