saveFile method

Future<String?> saveFile(
  1. {String? dialogTitle,
  2. String? fileName,
  3. String? initialDirectory,
  4. FileType type = FileType.any,
  5. List<String>? allowedExtensions,
  6. bool lockParentWindow = false}
)

Opens a save file dialog which lets the user select a file path and a file name to save a file.

This function does not actually save a file. It only opens the dialog to let the user choose a location and file name. This function only returns the path to this (non-existing) file.

This method is only available on desktop platforms (Linux, macOS & Windows).

dialogTitle can be set to display a custom title on desktop platforms.

fileName can be set to a non-empty string to provide a default file name. Throws an IllegalCharacterInFileNameException under Windows if the given fileName contains forbidden characters.

initialDirectory can be optionally set to an absolute path to specify where the dialog should open. Only supported on Linux, macOS, and Windows.

The file type filter type defaults to FileType.any. Optionally, allowedExtensions might be provided (e.g. [pdf, svg, jpg].). Both parameters are just a proposal to the user as the save file dialog does not enforce these restrictions.

If lockParentWindow is set, the child window (file picker window) will stay in front of the Flutter window until it is closed (like a modal window). This parameter works only on Windows desktop.

Returns null if aborted. Returns a Future<String?> which resolves to the absolute path of the selected file, if the user selected a file.

Implementation

Future<String?> saveFile({
  String? dialogTitle,
  String? fileName,
  String? initialDirectory,
  FileType type = FileType.any,
  List<String>? allowedExtensions,
  bool lockParentWindow = false,
}) async =>
    throw UnimplementedError('saveFile() has not been implemented.');