package Ġcom . sp itch enko . poke app . component . lifecycle Ċ Ċ import Ġandroidx . lifecycle . Abstract Saved State ViewModel Factory Ċ import Ġandroidx . lifecycle . Saved State Handle Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . saved state . Saved State Registry Owner Ċ Ċ class ĠViewModel Factory ( ĊĠĠĠ Ġprivate Ġval Ġcre ators : ĠViewModel Providers , ĊĠĠĠ Ġsaved State Registry Owner : ĠSaved State Registry Owner Ċ ) Ġ: ĠAbstract Saved State ViewModel Factory ( saved State Registry Owner , Ġnull ) Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġ< T Ġ: ĠViewModel > Ġcreate ( ĊĠĠĠĠĠĠĠ Ġkey : ĠString , ĊĠĠĠĠĠĠĠ Ġmodel Class : ĠClass < T >, ĊĠĠĠĠĠĠĠ Ġhandle : ĠSaved State Handle ĊĠĠĠ Ġ): ĠT Ġ{ ĊĊĠĠĠĠĠĠĠ Ġval Ġcreator Ġ= Ġcre ators [ model Class ] ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġcre ators . as Iterable (). first OrNull Ġ{ Ġmodel Class . isAssignableFrom ( it . key ) Ġ} ?. value ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalArgumentException (" unknown Ġmodel Ġclass Ġ$ model Class ") ĊĊĠĠĠĠĠĠĠ Ġ@ Suppress (" UN CHECK ED _ CAST ") ĊĠĠĠĠĠĠĠ Ġreturn Ġcreator . create ( handle ) Ġas ĠT ĊĠĠĠ Ġ} Ċ }