kevin
05/21/2024, 10:45 AMimport androidx.lifecycle.ViewModel
class MyViewModel : ViewModel() {
I can use that view model in my composable:
@Composable
fun MainScreen() {
val viewModel = viewModel<MyViewModel>()
This all appears to work.
However, as soon as I try and use that composable inside navigation :
NavHost(
navController = navController,
...
) {
composable(Screen.Start.name) {
MainScreen()
}
}
I get this:
``Factory.create(String, CreationExtras)` is not implemented. You may need to override the method and provide a custom implementation. Note that using Factory.create(String)
is not supported and considered an error.`
I created the app using the KMP wizard (desktop only), added the org.jetbrains.androidx.navigation:navigation-compose
library (I’ve tried both 2.7.0-alpha07 and 2.8.0-alpha02) and modified it as little as possible to set up navigationIvan Matkov
05/21/2024, 11:46 AMval viewModel = viewModel { MyViewModel() }
kevin
05/21/2024, 12:26 PMAlexander Maryanovsky
05/21/2024, 1:56 PMcode goes here
kevin
05/21/2024, 1:59 PM