Skip to main content
Open the system share sheet so the user can send files to another app. Call it from a source set that only includes Android and iOS, such as mobileMain (see shared source sets).
iOS share sheet for a JPEG image, with Reminders, Copy, Print, and Assign to Contact actionsAndroid share sheet previewing an image, with Quick Share, Photos, Print, Drive, and Maps targets

Usage

Sharing has no result: a completed share and a dismissed sheet look the same. Failures go to onError in Compose, or are thrown as a FileKitDialogException by the suspend API. See Results and errors.

Options

PlatformFile | List<PlatformFile>
required
launch()
What to share. An empty list does nothing.
FileKitShareSettings
default:"createDefault()"
rememberShareFileLauncher
Platform-specific settings. In the suspend API, pass it to shareFile().

Platform notes

Android setup

Only needed for files outside FileKit.filesDir and FileKit.cacheDir. filekit-dialogs already ships a FileProvider (${applicationId}.FileKitFileProvider) that covers those two directories, and content:// files returned by the pickers need no provider at all. For any other location, such as getExternalFilesDir(), FileProvider throws an IllegalArgumentException until you declare your own provider.
1

Declare a provider in your manifest

AndroidManifest.xml
2

List the directories it may expose

Add one entry per location you use, for example app-specific external storage:
res/xml/file_paths.xml
See FileProvider for every path type.
3

Pass the authority to FileKit

The authority parameter exists only on Android, so build these settings in androidMain:
androidMain
A custom authority applies to every file in the share. If you share files from several directories at once, for example filesDir and getExternalFilesDir(), your provider’s file_paths.xml must cover all of them. Otherwise FileKit throws an IllegalArgumentException before the share sheet opens.