pickFile static method
- String? dialogTitle,
- String? initialDirectory,
- FileType type = FileType.any,
- List<
String> ? allowedExtensions, - dynamic onFileLoading()?,
- int compressionQuality = 0,
- @Deprecated('Use WindowsOptions.lockParentWindow or LinuxOptions.lockParentWindow instead; this parameter will be removed in a future release.') bool lockParentWindow = false,
- @Deprecated('Use WebOptions.cancelUploadOnWindowBlur instead; this parameter will be removed in a future release.') bool cancelUploadOnWindowBlur = true,
- @Deprecated('Use androidOptions instead.') Object? androidSafOptions,
- AndroidOptions androidOptions = const AndroidOptions(),
- WindowsOptions windowsOptions = const WindowsOptions(),
- LinuxOptions linuxOptions = const LinuxOptions(),
- WebOptions webOptions = const WebOptions(),
Opens a native file explorer and lets the user select a single file.
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 file 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 androidOptions, windowsOptions, linuxOptions, and webOptions parameters
allow for platform-specific configurations when configuring the file picker.
Returns a PlatformFile object if a file was selected, or null if the user canceled the operation.
Implementation
static Future<PlatformFile?> pickFile({
String? dialogTitle,
String? initialDirectory,
FileType type = FileType.any,
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileLoading,
int compressionQuality = 0,
@Deprecated(
'Use WindowsOptions.lockParentWindow or LinuxOptions.lockParentWindow instead; this parameter will be removed in a future release.',
)
bool lockParentWindow = false,
@Deprecated(
'Use WebOptions.cancelUploadOnWindowBlur instead; this parameter will be removed in a future release.',
)
bool cancelUploadOnWindowBlur = true,
@Deprecated('Use androidOptions instead.') Object? androidSafOptions,
AndroidOptions androidOptions = const AndroidOptions(),
WindowsOptions windowsOptions = const WindowsOptions(),
LinuxOptions linuxOptions = const LinuxOptions(),
WebOptions webOptions = const WebOptions(),
}) {
return FilePickerPlatform.instance.pickFile(
dialogTitle: dialogTitle,
initialDirectory: initialDirectory,
type: type,
allowedExtensions: allowedExtensions,
onFileLoading: onFileLoading,
compressionQuality: compressionQuality,
androidOptions: _resolveAndroidOptions(androidSafOptions, androidOptions),
windowsOptions: windowsOptions,
linuxOptions: linuxOptions,
webOptions: webOptions,
);
}