arun
arun

Reputation: 215

How to use null as default value - Compose mutableState

I have a need like on first time on UI load the mutableStateOf Boolean value must be null , instead of default value as true/false similar to regular boolean value in Kotlin as

var isBooleanValue: Boolean = null

what I need is as below

var isClassAccessedAtleastOnce = remember {  mutableStateOf(null) }

Kindly let me know is there any possibility from the useCase

Upvotes: 6

Views: 6309

Answers (1)

Thracian
Thracian

Reputation: 66609

Define type of variable as

var isClassAccessedAtleastOnce = remember { mutableStateOf<Boolean?>(null) }

Upvotes: 21

Related Questions