saveFile static method
- required String fileName,
- required Uint8List bytes,
- String mimeType = 'application/octet-stream',
- String? dialogTitle,
- String? initialDirectory,
- FileType type = FileType.any,
- List<
String> ? allowedExtensions, - dynamic onFileSaving()?,
- @Deprecated('Use WindowsOptions.lockParentWindow or LinuxOptions.lockParentWindow instead; this parameter will be removed in a future release.') bool lockParentWindow = false,
- WindowsOptions windowsOptions = const WindowsOptions(),
- LinuxOptions linuxOptions = const LinuxOptions(),
- WebOptions webOptions = const WebOptions(),
Opens a save file dialog to let the user select a location and a file name to
save bytes to.
The fileName parameter specifies the default file name for saving (e.g. myFile.txt).
The bytes parameter contains the raw byte data to write.
The mimeType parameter specifies the MIME type of the file (e.g. application/pdf).
The dialogTitle, if provided, will be used as the title for the save file dialog.
The initialDirectory, if provided, will be used as the initial directory path for the save file dialog.
The onFileSaving callback, if provided, is triggered when the save dialog changes status.
The windowsOptions, linuxOptions, and webOptions parameters
allow for platform-specific configurations when configuring the save file dialog.
Returns the Uri of the saved file, or null if the user canceled the operation.
Depending on the platform, the Uri.scheme may be file, content, http(s), data or blob.
Implementation
static Future<Uri?> saveFile({
required String fileName,
required Uint8List bytes,
String mimeType = 'application/octet-stream',
String? dialogTitle,
String? initialDirectory,
FileType type = FileType.any,
List<String>? allowedExtensions,
Function(FilePickerStatus)? onFileSaving,
@Deprecated(
'Use WindowsOptions.lockParentWindow or LinuxOptions.lockParentWindow instead; this parameter will be removed in a future release.',
)
bool lockParentWindow = false,
WindowsOptions windowsOptions = const WindowsOptions(),
LinuxOptions linuxOptions = const LinuxOptions(),
WebOptions webOptions = const WebOptions(),
}) {
return FilePickerPlatform.instance.saveFile(
fileName: fileName,
bytes: bytes,
mimeType: mimeType,
dialogTitle: dialogTitle,
initialDirectory: initialDirectory,
onFileSaving: onFileSaving,
windowsOptions: windowsOptions,
linuxOptions: linuxOptions,
webOptions: webOptions,
);
}