'How do ask a permission for open a gallery in android phones using flutter
I have using image_picker: ^0.8.4+11 for open a gallery. I need to ask a permission for open a gallery. In iOS it ask a permission to open a gallery but Android it did not ask a permission
I have tried like this in my AndroidManifest file
but it did not work to me. could you please any one can help me to solve this issue.
Thanks in advance.
Solution 1:[1]
// These permission are required to be added to your AndroidManifest.xml
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
// Add these to android/grade.properties file.
android.useAndroidX=true
android.enableJetifier=true
// Get from gallery
_getFromGallery() async {
PickedFile pickedFile = await ImagePicker().getImage(
source: ImageSource.gallery,
maxWidth: 1800,
maxHeight: 1800,
);
if (pickedFile != null) {
File imageFile = File(pickedFile.path);
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |