Hello, I am trying to “multiplatform” the ViewMode...
# multiplatform
g
Hello, I am trying to “multiplatform” the ViewModel class from androidx:
Copy code
public abstract class ViewModel {
    protected void onCleared() {
    }
}
I hoped the following would work:
Copy code
expect abstract class ViewModel {
     protected fun onCleared()
}
And on Android declare it this way:
Copy code
actual typealias ViewModel = androidx.lifecycle.ViewModel
But because protected means different things in Kotlin and Java, I get the following error:
protected final expect fun onCleared(): Unit
is incompatible because visibility is different from
protected/*protected and package*/ open fun onCleared(): Unit
. Am I stuck here or is there a way to go around this?
y
r
g
Thank you @yshrsmz and @russhwolf 🙂