getOrThrow

fun <T : ViewModel> getOrThrow(    owner: ViewModelStoreOwner,     kotlinClass: KClass<*>,     key: String): T

Returns an existing ViewModel or throws an exception when no matching view model can be restored.

Parameters

owner

The ViewModelStoreOwner owning the store.

kotlinClass

The KClass information on the ViewModel being retrieved.

key

Unique identifier for this ViewModel.

Throws

when no ViewModel can be found in the owner's store.