package Ġcom . ark iv an ov . de compose . state keeper Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . saved state . Saved State Registry Ċ Ċ private Ġconst Ġval ĠKEY _ STATE Ġ= Ġ" STATE _ KE E PER _ STATE " Ċ Ċ /** Ċ Ġ* ĠCreates Ġa Ġnew Ġinstance Ġof Ġ[ State Keeper ] Ġand Ġatt aches Ġit Ġto Ġthe Ġprovided Ġ[ Saved State Registry ]. Ċ Ġ* Ċ Ġ* Ġ@ param Ġis Saving Allowed Ġcalled Ġbefore Ġsaving Ġthe Ġstate . Ċ Ġ* ĠWhen Ġ` true ` Ġthen Ġthe Ġstate Ġwill Ġbe Ġsaved , Ġotherwise Ġit Ġwon 't . ĠDefault Ġvalue Ġis Ġ` true `. Ċ Ġ*/ Ċ fun ĠState Keeper ( ĊĠĠĠ Ġsaved State Registry : ĠSaved State Registry , ĊĠĠĠ Ġis Saving Allowed : Ġ() Ġ-> ĠBoolean Ġ= Ġ{ Ġtrue Ġ} Ċ ): ĠState Keeper Ġ{ ĊĠĠĠ Ġval Ġdispatcher Ġ= ĠState Keeper Dispatcher ( saved State Registry . consume Restore d State ForKey ( KEY _ STATE )?. get Parcelable ( KEY _ STATE )) ĊĊĠĠĠ Ġsaved State Registry . register Saved State Provider ( KEY _ STATE ) Ġ{ ĊĠĠĠĠĠĠĠ ĠBundle (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( is Saving Allowed ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġput Parcelable ( KEY _ STATE , Ġdispatcher . save ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġdispatcher Ċ } Ċ Ċ @ Deprecated (" Use ĠState Keeper ( Saved State Registry ) Ġbuilder Ġfunction ", ĠReplace With (" State Keeper ( this ) ")) Ċ fun ĠSaved State Registry . to State Keeper (): ĠState Keeper Ġ= ĠState Keeper ( this ) ĊĊ