Let users pick photos and videos with the native gallery on Android and iOS
Pass FileKitType.Image, Video, or ImageAndVideo to the file picker. On Android and iOS it opens the system photo picker; on other targets it opens a file dialog filtered to media files.
val launcher = rememberFilePickerLauncher( type = FileKitType.Image, onError = { failure -> showError(failure.message) },) { image -> // image is a PlatformFile, or null when the user cancelled}Button(onClick = { launcher.launch() }) { Text("Pick a photo")}
val image: PlatformFile? = FileKit.openFilePicker(type = FileKitType.Image)
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.Every file picker option applies, including the state-tracking modes.
This is the FileKit sample running in your browser. Choose images, videos, or both, switch the selection mode, then open a file to inspect its metadata. In a browser the picker is a file input filtered to media files.
Use FileKitMode.Multiple(maxItems) with a value from 1 to 50. The same mode works on rememberFilePickerLauncher:
val media: List<PlatformFile>? = FileKit.openFilePicker( type = FileKitType.ImageAndVideo, mode = FileKitMode.Multiple(maxItems = 5),)
The iOS picker and the Android Photo Picker enforce the limit in their UI. When Android falls back to the document picker, and on other targets, the dialog canโt limit the selection, so FileKit keeps the first maxItems files.
iOS can return photos as HEIC, which some image decoders and servers canโt read. In iosMain, pass FileKitDialogSettings(assetRepresentationMode = FileKitAssetRepresentationMode.Compatible) as dialogSettings so iOS transcodes them to a more compatible format.