Reputation: 5069
According to those SO questions: UIImagePickerController not asking for permission and No permission to pick a photo from the photo library
If you want to select one image on iOS, you don't have to ask for permission to do it as the app doesn't actually access the gallery.
However, I can't find a way of doing it Flutter. Packages like ImagePicker always ask for permission.
Has anyone succeeded in picking an image in Flutter on iOS without asking for permission?
Upvotes: 7
Views: 2140
Reputation: 1060
We can use the official Flutter plugin - image_picker
IMPORTANT - make sure you pass requestFullMetadata
as false
.
final List<XFile> imageList =
await ImagePicker().pickMultiImage(requestFullMetadata: false);
It is true
by default (probably for maintaining backward compatibility in terms of behavior for apps which started using the plugin from the old versions before PHPicker )
Upvotes: 0
Reputation: 18157
The old UIImagePickerController
allowed it on older iOS'es, but it has been deprecated, since iOS 14.
The Flutter ImagePicker
plugin uses the PHPicker in the iOS code, as I checked for their code on Github, and it allows you to pick an image from the user without requesting permissions. I recommend highly to use that plugin.
Upvotes: 2
Reputation: 9727
From Apple documentation:
PHPickerViewController is a new picker that replaces UIImagePickerController. Its user interface matches that of the Photos app, supports search and multiple selection of photos and videos, and provides fluid zooming of content. Because the system manages its life cycle in a separate process, it’s private by default. The user doesn’t need to explicitly authorize your app to select photos, which results in a simpler and more streamlined user experience.
This library uses PHPickerViewController
as seen here
Upvotes: 3
Reputation: 1782
Try file_picker it should work for you as it supports all the platform including IOS and Mac supporting various types of file type, you can specify your custom file types also limiting your file selections as well as you can pick files from cloud (GDrive, Dropbox, iCloud)...
First of all add the latest file_picker
as a dependency in your pubspec.yaml
file.
Import this dependency in file wherever you want to use and then you are good to go...
for picking single file use this code:
FilePickerResult? result = await FilePicker.platform.pickFiles();
if (result != null) {
File file = File(result.files.single.path);
} else {
// User canceled the picker
}
files with extension filter:
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'pdf', 'doc'],
);
You can find detailed usage Here
you can find the documentation Here
Upvotes: 0