Skip to main content
Open the native save dialog. FileKit returns the location the user picked as a PlatformFile, and you write your data to it. The file saver is not available on the web, so call it from a non-web source set such as nonWebMain (see shared source sets).

Usage

The result is null when the user cancels. Failures go to onError in Compose, or are thrown as a FileKitDialogException by the suspend API. See Results and errors.

Options

String
required
launch()
File name without the extension.
String?
default:"null"
launch()
Extension without the dot, appended to suggestedName.
Set<String>?
default:"null"
launch()
Save types offered by the dialog, without dots. A hint, not a validation.
PlatformFile?
default:"null"
launch()
Initial folder. Ignored on Android.
FileKitDialogSettings
default:"createDefault()"
rememberFileSaverLauncher
Required by the Compose launcher. In a Compose Desktop Window, WindowScope.rememberFileSaverLauncher makes it optional and parents the dialog to the window. See Dialog settings.

Offer several file types

Pass allowedExtensions to let the user pick a format. defaultExtension stays the preselected one:
Not every platform enforces the filter, so check file.extension if your app needs a specific format.

Download file on the web

Browsers don’t let you choose a save location: use FileKit.download to send bytes to the user’s downloads folder instead. See Download files.

Platform notes

The extension parameter of openFileSaver and launch() is deprecated. Rename it to defaultExtension; the behavior is the same.