I am trying to preview a Composable that uses koin dependencies. Per the documentation here you should be able to start a mini KoinApplication in the Preview function to pass the dependency to the preview.
But I still get the following error:
Render problem
java.lang.IllegalStateException: KoinApplication has not been started
at org.koin.core.context.GlobalContext.get(GlobalContext.kt:36)
at org.koin.core.component.KoinComponent$DefaultImpls.getKoin(KoinComponent.kt:33)
at com.xyz.utility.MyHelper.getKoin(MyHelper.kt:38)
at com.xyz.utility.MyHelper$special$$inlined$inject$default$5.invoke(KoinComponent.kt:68)
....
Here is my preview function
@Preview
@Composable
fun PreferencesPreview() {
KoinApplication(application = {
// your preview config here
modules(
databaseModule,
networkModule,
//etc...
)
}) {
// Compose to preview with Koin
Preferences()
}
}