[英]Flutter File picker unable to select image from Android Gallery
I am using file_picker 5.0.1 , while selecting image from Android device Gallery app it shows this error.我正在使用file_picker 5.0.1 ,从 Android 设备库应用程序中选择图像时,它显示此错误。
I/FilePickerDelegate(26740): User cancelled the picker request
This is the code snippet, I am using to call file picker这是代码片段,我用来调用文件选择器
FilePickerResult? result =
await FilePicker.platform
.pickFiles(
type: FileType.image,
allowMultiple: false,
allowCompression: false,
});
if (result != null) {
print(result.files.length);
}
My flutter version: 3.0.5 Android compileSdkVersion: 31 Android minSdkVersion: 19 Android targetSdkVersion: 31 My flutter version: 3.0.5 Android compileSdkVersion: 31 Android minSdkVersion: 19 Android targetSdkVersion: 31
Check permission is granted and at least one album app is installed in the phone.检查权限是否被授予并且手机中至少安装了一个相册应用程序。 Also you can try
你也可以试试
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'png'],
);
or use this package https://pub.dev/packages/image_picker或使用此 package https://pub.dev/packages/image_picker
This worked for me https://github.com/miguelpruivo/flutter_file_picker/issues/717#issuecomment-847801191这对我有用 https://github.com/miguelpruivo/flutter_file_picker/issues/717#issuecomment-847801191
Updated my AndroidManifest.xml
更新了我的
AndroidManifest.xml
Before前
android:launchMode="singleInstance"
After后
android:launchMode="singleTask"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.