pickFiles static method
- String? dialogTitle,
- String? initialDirectory,
- FileType type = FileType.any,
- List<
String> ? allowedExtensions, - dynamic onFileLoading()?,
- int compressionQuality = 0,
- AndroidOptions androidOptions = const AndroidOptions(),
- DarwinOptions darwinOptions = const DarwinOptions(),
- WindowsOptions windowsOptions = const WindowsOptions(),
- LinuxOptions linuxOptions = const LinuxOptions(),
- WebOptions webOptions = const WebOptions(),
Retrieves the file(s) from the underlying platform.
Opens a native file explorer and lets the user select one or multiple files.
The dialogTitle, if provided, will be used as the title for the picker dialog.
The initialDirectory, if provided, will be used as the initial directory path for the picker.
The type parameter defines the type of files that can be selected (e.g. FileType.image, FileType.video, etc.).
The allowedExtensions parameter can be used to filter by specific file extensions when type is set to FileType.custom.
The onFileLoading callback can be used to track picker status changes.
The compressionQuality parameter allows compressing picked images/videos on supported platforms (0-100).
The darwinOptions parameter configures iOS photo-library asset representation.
The androidOptions, darwinOptions, windowsOptions, linuxOptions, and webOptions parameters
allow for platform-specific configurations when configuring the file picker.
Returns a list of PlatformFile objects containing the selected files, or an empty list if the user canceled the operation.
Implementation
static Future<List<PlatformFile>> pickFiles({
String? dialogTitle,
String? initialDirectory,
FileType type = FileType.any,
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileLoading,
int compressionQuality = 0,
AndroidOptions androidOptions = const AndroidOptions(),
DarwinOptions darwinOptions = const DarwinOptions(),
WindowsOptions windowsOptions = const WindowsOptions(),
LinuxOptions linuxOptions = const LinuxOptions(),
WebOptions webOptions = const WebOptions(),
}) {
darwinOptions.validate(compressionQuality);
return FilePickerPlatform.instance.pickFiles(
dialogTitle: dialogTitle,
initialDirectory: initialDirectory,
type: type,
allowedExtensions: allowedExtensions,
onFileLoading: onFileLoading,
compressionQuality: compressionQuality,
androidOptions: androidOptions,
darwinOptions: darwinOptions,
windowsOptions: windowsOptions,
linuxOptions: linuxOptions,
webOptions: webOptions,
);
}