I'm using the Flutter Image Cropper plugin. The first time I build the app and try to crop an image, the app crashes when I click to save the cropped image. But if I rebuild the app, it works perfectly. I think this may be related to permissions as I had a very similar problem with audio record permissions. This was solved by using the Permissions Plugin to request all permissions at the top of the app.
The permissions I am requesting in my AndroidManifest.xml file are;
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.INTERNET"/>
I've also added this to the AndroidManifest.xml;
<activity
android:name="com.yalantis.ucrop.UCropActivity"
android:screenOrientation="portrait"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
/>
Here's the method I'm using to check permissions at the top of my widget tree;
Map<Permission, PermissionState> permission = await PermissionsPlugin
.checkPermissions([
Permission.CAMERA,
Permission.RECORD_AUDIO,
Permission.WRITE_EXTERNAL_STORAGE,
Permission.READ_EXTERNAL_STORAGE,
]);
Although the Permissions Plugin managed to solve the crashing of my app upon first build, it doesn't seem to have helped with the Flutter Image Cropper plugin.
Can anyone see what's going on?