Skip to main content
Every FileKit dialog separates three outcomes: a value, a user cancellation (null), and an operational failure (a FileKitDialogException). Invalid arguments and unexpected defects are never converted into failures: they propagate as the original exception.

Compose launchers

Use the launcher overloads that take onError. The trailing lambda is onResult:
rememberFilePickerLauncher passes a FileKitPickerException (the picker subtype of FileKitDialogException) to onError. The directory picker, file saver, camera, and share launchers pass a FileKitDialogException. If a dialog never appears on iOS, check where the launcher is remembered: see Compose launchers.

Suspend API

The FileKit.open… functions return null when the user cancels and throw on operational failures:
Coroutine cancellation and invalid arguments (for example maxItems outside 1..50) propagate as usual. Catch FileKitDialogException to handle every dialog failure in one place.

State-tracking picker modes

FileKitMode.SingleWithState and MultipleWithState deliver progress and their terminal outcome as FileKitPickerState values, through onResult in Compose or the returned Flow in the suspend API:
  • Started and Progress are non-terminal values.
  • Exactly one of Completed, Cancelled, or Failed is the terminal value.
  • FileKitPickerState.Failed is data: it is not duplicated through onError.
  • A picker failure thrown outside the state stream reaches onError (or is thrown while collecting the flow).
  • Coroutine cancellation stops delivery and produces no later terminal value.

Sharing

Sharing has no success callback. A successful share launch, including user dismissal after the system share sheet appears, stays callback-less. A FileKit-owned operational failure reaches onError. Coroutine cancellation, invalid invocations, unexpected defects, and callback exceptions propagate.

Compatibility overloads

Launcher overloads without onError remain available for source and binary compatibility. They keep their historical callback shape and ignore operational failures without logging. They still propagate coroutine cancellation, invalid invocations, unexpected defects, and exceptions thrown by your callbacks. Prefer the onError overloads in new code so failures are visible.