openFilePicker shows the platform’s native file dialog and returns the selected file as a PlatformFile, or a list of files in multiple mode.
Usage
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.
Try it
This is the FileKit sample running in your browser. Pick files, switch the selection mode or restrict extensions, then open a file to inspect its metadata.Options
In Compose, pass these options torememberFilePickerLauncher. launch() takes no arguments.
FileKitType
default:"File()"
Which files the user can pick.
File() allows any file.FileKitMode
default:"Single"
How many files the user can pick. The result type follows the mode.
PlatformFile?
default:"null"
Folder the dialog opens in. Ignored on Android and the web.
FileKitDialogSettings
default:"createDefault()"
Title, parent window, and other per-platform settings.
Filter by extension
Pass the extensions without the dot:FileKitType.File also accepts a List<String> or a Set<String>.
Pick multiple files
FileKitMode.Multiple() returns a List<PlatformFile>, or null when the user cancels:
maxItems in their UI. Other dialogs, including Android’s document picker fallback, have no native limit, so FileKit keeps the first maxItems files in the order the platform returns them.
Track progress
SingleWithState and MultipleWithState report each step as a FileKitPickerState, which lets you show a loading indicator while large files are prepared. In Compose, each state reaches onResult. The suspend API returns a Flow:
Platform notes
Related
- Gallery picker for photos and videos.
- Reading files once the user has picked it.
- Results and errors for cancellation and failure handling.