Kodein integration
To use the rememberScreenModel you should first import cafe.adriel.voyager:voyager-kodein (see Setup).
Declare your ScreenModels using the bindProvider bind.
val homeModule = DI.Module(name = "home") {
bindProvider { HomeScreenModel() }
}
Call rememberScreenModel() to get a new instance.
class HomeScreen : Screen {
@Composable
override fun Content() {
val screenModel = rememberScreenModel<HomeScreenModel>()
// ...
}
}

Sample

Sample code here.
Copy link