0
0
Android Kotlinmobile~10 mins

remember and mutableStateOf in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a mutable state variable that remembers its value across recompositions.

Android Kotlin
val count = [1] { mutableStateOf(0) }
Drag options to blanks, or click blank then click option'
Aremember
BmutableStateOf
CmutableState
DstateOf
Attempts:
3 left
💡 Hint
Common Mistakes
Using mutableStateOf without remember causes state to reset on recomposition.
Confusing remember with mutableStateOf.
2fill in blank
medium

Complete the code to declare a mutable state integer variable initialized to 0.

Android Kotlin
var count by [1] { mutableStateOf(0) }
Drag options to blanks, or click blank then click option'
Aremember
BmutableStateOf
CstateOf
DmutableState
Attempts:
3 left
💡 Hint
Common Mistakes
Using mutableStateOf alone without remember.
Using stateOf which is immutable.
3fill in blank
hard

Fix the error in the code to properly remember a mutable state string initialized to "Hello".

Android Kotlin
val text = remember { [1]("Hello") }
Drag options to blanks, or click blank then click option'
AstateOf
Bremember
CmutableStateOf
DmutableState
Attempts:
3 left
💡 Hint
Common Mistakes
Using stateOf instead of mutableStateOf.
Using remember inside itself.
4fill in blank
hard

Fill both blanks to create a mutable state variable that remembers a Boolean value initialized to false.

Android Kotlin
var isChecked by [1] { [2](false) }
Drag options to blanks, or click blank then click option'
Aremember
BmutableStateOf
CstateOf
DmutableState
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping remember and mutableStateOf.
Using stateOf which is immutable.
5fill in blank
hard

Fill all three blanks to create a mutable state variable that remembers a String initialized to "Compose" and is mutable.

Android Kotlin
var title by [1] { [2]("[3]") }
Drag options to blanks, or click blank then click option'
Aremember
BmutableStateOf
CCompose
DstateOf
Attempts:
3 left
💡 Hint
Common Mistakes
Using stateOf instead of mutableStateOf.
Forgetting to use remember.
Putting the initial value outside the quotes.