|
| 1 | +# File Dialog |
| 2 | + |
| 3 | +Nucleus does not ship a file/folder picker module. The Compose Multiplatform ecosystem already has an excellent native solution. |
| 4 | + |
| 5 | +## Recommended: FileKit |
| 6 | + |
| 7 | +[**FileKit**](https://github.com/vinceglb/FileKit) by [@vinceglb](https://github.com/vinceglb) — native file pickers and file operations for Compose Multiplatform, including JVM Desktop. |
| 8 | + |
| 9 | +```kotlin |
| 10 | +dependencies { |
| 11 | + implementation("io.github.vinceglb:filekit-compose:<version>") |
| 12 | +} |
| 13 | +``` |
| 14 | + |
| 15 | +```kotlin |
| 16 | +val launcher = rememberFilePickerLauncher( |
| 17 | + type = PickerType.File(extensions = listOf("png", "jpg")), |
| 18 | + title = "Pick an image", |
| 19 | +) { file -> |
| 20 | + // file: PlatformFile? |
| 21 | +} |
| 22 | + |
| 23 | +Button(onClick = { launcher.launch() }) { |
| 24 | + Text("Pick image") |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +### What it covers |
| 29 | + |
| 30 | +- Native open / save / folder pickers on macOS (`NSOpenPanel` / `NSSavePanel`), Windows (`IFileOpenDialog` / `IFileSaveDialog`), and Linux (xdg-desktop-portal `FileChooser` with fallback to GTK / zenity) |
| 31 | +- File type filters with descriptions |
| 32 | +- Single-file, multi-file, folder, and save modes |
| 33 | +- Compose-friendly API with `rememberFilePickerLauncher` |
| 34 | +- Cross-platform `PlatformFile` abstraction with read / write / metadata helpers |
| 35 | + |
| 36 | +### Why Nucleus doesn't ship this |
| 37 | + |
| 38 | +FileKit already covers the full surface natively, has active maintenance, and integrates cleanly with Compose state. Reimplementing it inside Nucleus would duplicate effort with no benefit. |
| 39 | + |
| 40 | +### GraalVM native image — zero config |
| 41 | + |
| 42 | +The Nucleus Gradle plugin ships **preloaded reachability metadata for FileKit** as part of its [library metadata bundle](../graalvm/automatic-metadata.md). The metadata is conditionally included only when `io.github.vinceglb.filekit` is present on your runtime classpath, and covers: |
| 43 | + |
| 44 | +- macOS Foundation proxy + callback types (`FoundationLibrary`, `ID`, runnable callbacks) |
| 45 | +- Windows JNA COM bindings (`FileDialog`, `FileOpenDialog`, `FileSaveDialog`, `ShellItem`, `Shell32`, `COMDLG_FILTERSPEC`, `PROPERTYKEY`, …) |
| 46 | +- XDG desktop-portal D-Bus proxy (`FileChooserDbusInterface`) for Linux |
| 47 | + |
| 48 | +So if you package with the Nucleus plugin and target `native-image`, FileKit works out of the box — no manual entries in `reachability-metadata.json`, no tracing-agent run required. |
0 commit comments