Hello, I am trying to “multiplatform” the ViewModel class from
androidx:
public abstract class ViewModel {
protected void onCleared() {
}
}
I hoped the following would work:
expect abstract class ViewModel {
protected fun onCleared()
}
And on Android declare it this way:
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?