Questions tagged [mutablestateof]
33 questions
0
votes
1 answer
Compose UI not updating the state after updating the view model
I am trying to update a compose UI view based on the state changes in the view model, below is my code Initially i am making assigning and doing operation by the default value from view model to a compose logic handling and after some time I will be…

arun
- 95
- 13
0
votes
1 answer
MutableStateOf of mutableList not updating
Why my mutableStateOf of mutableList not updating?
val checkedList by remember {
mutableStateOf(MutableList(list.size) { false })

Slava
- 443
- 4
- 12
0
votes
1 answer
UI not updating properly on first launch of app Android Compose
I have the following code in my HomePageViewModel:
private val _overallStitchCount: MutableStateFlow = MutableStateFlow(0)
val overallStitchCount: StateFlow = _overallStitchCount
...
init {
projectRepo = projectRepository
…

JamieRhys
- 206
- 6
- 24
0
votes
0 answers
UI not updating when viewmodel variable has changed jetpack compose
My variable is defined as follows in my view model:
private val _overallStitchCount: MutableStateFlow = MutableStateFlow(0)
val overallStitchCount: StateFlow = _overallStitchCount
If I then insert a project into my room database as…

JamieRhys
- 206
- 6
- 24
0
votes
0 answers
MutableStateFlow does not emitting value changes
Case is,I'm scanning hardware with NFC and getting texts from it,it has some steps to receive texts.for example:
step 1 - starting scan,
step 2 - scan in progress,
step 3 - scan is almost finished,
step 4 - scan is finished.
Problem is when I send…

Daviti Gogochishvili
- 33
- 3
0
votes
1 answer
printing mutableState parameters
I have a class Plan() that has the parameter "val changeNumber : MutableState".
as in
Plan(
...
val changeNumber : MutableState
...
){}
I want to display this value on the screen but when I use plan.changeNumber.toString() it…

IrrGuy
- 15
- 3
0
votes
1 answer
Variable not updated in compose
I have a class in Kotlin (Jetpack compose) with a variable title and an exoplayer that updates the title.
class Player{
var title by mutableStatOf("value")
....
title= "new value"
...
}
@Composable
fun Display(){
val player =…

sigjak
- 129
- 1
- 1
- 9
0
votes
4 answers
Listen to changes in only particular object in a StateFlow of type List?
How to listen to only a particular element in the MutableStateFlow of type list? If we listen to the entire list, then all the Views that are listening to the list if changed would rebuild themselves which I do not want.
class ArticleViewModel:…

Muhammad Haroon
- 61
- 1
- 8
0
votes
1 answer
Text and Button Color not updating when MutableState object changes
For the below code, I'm trying to get the selectedColorsText to update whenever a user clicks on a button. The button background should then turn black and the text inside it white once selected. If de-selected, the button should turn back to…

Vaz
- 309
- 2
- 15
0
votes
0 answers
Jetpack Compose: What does it mean for an operation to 'enter' or 'leave'
From: https://developer.android.com/jetpack/compose/side-effects
"To call suspend functions safely from inside a composable, use the
LaunchedEffect composable. When LaunchedEffect enters the Composition,
it launches a coroutine with the block of…

Regress.arg
- 352
- 6
- 16
0
votes
1 answer
Jet Pack Compose Mutable List Updating With Mutable State list Problem
//declared in activity
val statebilledproducts = viewModel.listBilledProducts
//declared in viewmodel
class OrderViewModel : ViewModel() {
private val _listBilledProducts = mutableStateListOf()
val listBilledProducts…
0
votes
0 answers
mutableStateListOf not doing recomposition on replacing some element in the list with targetsdk 33 and kotlin 1.7.20
Recomposition will happen only when you change the list itself. mutableStateListOf can only notify about adding, removing, or replacing some element in the list.
Reference: Android Jetpack Compose mutableStateListOf not doing Recomposition
Based on…

Android Developer
- 9,157
- 18
- 82
- 139
0
votes
1 answer
Attempt to invoke interface method on a null object reference in kotlin
After implementing viewmodels to jetpack compose app when I running the app it's showing a error :-
Attempt to invoke interface method 'boolean java.util.Set.contains(java.lang.Object)' on a null object reference
java.lang.NullPointerException:…
0
votes
2 answers
How to update UI with a viewModel for byte arrays and lists in Kotlin/Jetpack Compose?
So the problem I am facing is that when the viewModel data updates it doesn't seems to update the state of my bytearrays: ByteArray by (mutableStateOf) and mutableListOf()
When I change pages/come back to the page it does update them again. How can…

Swifty
- 15
- 5
0
votes
0 answers
Test that value contained in MutableState is updated correctly
I have a viewModel that looks like this
class PhotoViewModel(
private val getPhotoUseCase: GetPhotoUseCase
) : ViewModel() {
val photo: MutableState =
mutableStateOf(null)
fun getPhotoDetail(photoId: Int) {
…

Gianluca Veschi
- 1,239
- 1
- 14
- 20