Installation

FileKit can helps you to display dialogs to the user like file, directory and photo pickers, save dialogs, camera and more. FileKit dialogs are available in two flavors:

// Enables FileKit dialogs without Compose dependencies
implementation("io.github.vinceglb:filekit-dialogs:0.10.0-beta01")

// Enables FileKit dialogs with Composable utilities
implementation("io.github.vinceglb:filekit-dialogs-compose:0.10.0-beta01")

FileKit Dialogs integrates FileKit Core and automatically provides PlatformFile support.

Platform-specific setup

It’s required to setup FileKit Dialogs on Android and JVM targets. All other platforms are supported out of the box.

Android setup

Using needs an initialization step in your Android application.

This initialization step is not needed when using filekit-dialogs-compose.

FileKit needs to have access to the ActivityResultRegistry to handle the result of the file picker dialog. To do this, you need to add the following code to your MainActivity:

MainActivity.kt
class MainActivity : ComponentActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)

    // Initialize FileKit
    FileKit.init(this)
  }
}

JVM setup

FileKit needs to have your application id to handle the app directory. Your application id is generally the package name or the name of your application. FileKit will use this appId as app directory.

We recommend you to initialize FileKit in your main.kt file:

main.kt
fun main() = application {
  // Initialize FileKit
  FileKit.init(appId = "MyApplication")

  // Start your application
  Window(onCloseRequest = ::exitApplication) {
    // ...
  }
}

Linux setup

If using JVM target and Linux distribution, you need to add the following module in your build.gradle.kts file:

build.gradle.kts
compose.desktop {
    application {
        nativeDistributions {
            linux {
                modules("jdk.security.auth")
            }
        }
    }
}

This prevents a NoClassDefFoundError in some cases. Read more about this issue in the GitHub issue #107.