Questions tagged [mutablestateof]
33 questions
8
votes
1 answer
Jetpack Compose TextField not updating when typing a new character
I followed this document from the developer site.
I want to display the text in an OutlinedTextField from a user input, and have it survive configuration changes.
With the code below, when the user inputs the text from the keyboard,…

Zappy.Mans
- 551
- 1
- 7
- 19
3
votes
1 answer
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…

arun
- 95
- 13
2
votes
1 answer
Android Jetpack Compose rememberSystemUiController() doesn't observe mutableStateOf()
I'm trying to achieve a hide/show functionality for status bar in an AbstractComposeView
class MyView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AbstractComposeView(context, attrs,…

Gonki
- 567
- 1
- 8
- 17
2
votes
2 answers
mutableStateOf holding the value after the recomposition without remember API in Jetpack Compose
Any time a state is updated a recomposition takes place.
but here, I haven't used the remember API, but after the recomposition also it's holding the value, is the mutableStateOf() will remember the value without remember API?
@Composable
fun…

FGH
- 2,900
- 6
- 26
- 59
1
vote
1 answer
How SnapshotStateList detects that a change has occurred?
Suppose I have a SnapshotStateList for Student, and the definition of Student is:
data class Student
val students = mutableStateListOf(Student(0, "Aaron"))
My Jetpack compose in wants to recompose when students…

progquester
- 1,228
- 14
- 23
1
vote
0 answers
Checkbox in Jetpack compose not updating with the state value
I am creating a list of data to be multi selected and also want to add functionality by adding "Select All" option to select/deselect all the items at once.
The issue I am facing is when checked the specific item, it is being checked/unchecked and…

Chintak Patel
- 748
- 6
- 24
1
vote
0 answers
Compose Android - Update a Item from list without page refresh
I have a LazyColumn list which holds user Items and I have populated the list Item view no issue on that, in here say I need to update a view from the Item like updating the user profile picture without updating the whole list but just making the…

arun
- 95
- 13
1
vote
1 answer
Can I update a list in StateFlow (and change Compose View) without manually generating a new one just to modify one value in the list?
I have a lazyColumn of todo item
data class TodoItem(val id: Int, val title: String, var urgent: Boolean = false)
class AppViewModel : ViewModel() {
private var todoList = mutableListOf(
TodoItem(0, "My First Task"),
…

Elye
- 53,639
- 54
- 212
- 474
1
vote
2 answers
Boolean State in compose is changing before the variable I put after it get's assigned
So I have Two ViewModels in my Calculator App in which I all reference in my Compose NavGraph so I can use the same ViewModel instance. I set a Boolean State(historyCheck) in the first ViewModel and I set it too true to "Clear" the History I set…

Daniel Iroka
- 103
- 8
1
vote
0 answers
Android, Jetpack Compose - Composable function not getting refreshed
I am new to Android Jetpack compose.
All i want to do is to update data in UI when it gets from API.
Here is my Composable function:
@Composable
fun getCurrentWeather(lat : Double, long : Double, nc : NavHostController,
vm:…

kinza
- 535
- 11
- 31
0
votes
1 answer
What is the syntax to make a callback function variable mutable in Jetpack Compose?
I'm trying to make the following variable, selectedView, mutable so that I can set the current Composable View dynamically.
var selectedView :@Composable () -> Unit = { testView() }
I'm passing back the Composable function and the following code…

J. Edgell
- 1,555
- 3
- 16
- 24
0
votes
0 answers
assertHistorySize() for State or MutableState in Android Test
I am used to use awaitValue + assertHistorySize to test how much a LiveData has received and what it has got.
So I write the following code (only as an example):
val dataObserver =…

androoby
- 1
- 2
0
votes
1 answer
Is passing mutablestate to composable function optimal?
Like this :
@Composable
fun TextEdit(textState: MutableState) {
val text by textState
TextField(onValueChange = {
text = it
}, value = text)
}
Is it optimal for unnecessary recompositions?

MH-Rouhani
- 81
- 1
- 7
0
votes
2 answers
Updating item in a mutableStateList is not triggering recomposition in UI (LazyColumn)
I have been scratching my head over this problem.
I have a data class representing items that can be selected(or unselected).
data class FilterItem(
val name: String,
val isSelected: Boolean
)
I have created a mutableStateList of…

Ayush Patel
- 33
- 3
0
votes
0 answers
Question about atomized modifications to SnapshotStateList
I am using SnapshotStateList to maintain a list of Elements to feed the compose UI.
When I add, remove, and replace elements to this list, they trigger my LazyColumn component to recompose. this all works fine.
However, if during one of the…

progquester
- 1,228
- 14
- 23