I/flutter ( 3041): [MethodChannelFilePicker] Platform exception: PlatformException(read_external_storage_denied, User did not allow reading external storage, null, null)
Future<void> pickFile() async {
try {
FilePickerResult? result;
String? _fileName;
PlatformFile? pickedFile;
bool isLoading = false;
File? fileToDisplay;
result = await FilePicker.platform.pickFiles(
type: FileType.media,
allowMultiple: false,
);
if (result != null) {
_fileName = result!.files.first.name;
pickedFile = result!.files.first;
fileToDisplay = File(pickedFile!.path.toString());
print("file name:$_fileName");
} else {
// User canceled the picker
print('User canceled file picker');
}
} catch (e) {
showSnackBar(context, e.toString());
}
}
I am tring to upload file to flutter application but got user did not allowed external storage in application it is not asking for any permission
You must request storage permission first. add read external storage permission in android\app\src\main\AndroidManifest.xml
and request it by using permission_handler package.
example for the request: