Jetpack Compose: Surface makes state is persisting without remember

im currently experiencing with jetpack compose states. Check out this composable: @Composable fun CounterWithoutRemember(reset: MutableState<Boolean>) { val count = mutableStateOf(0) Box(Modifier.fillMaxWidth()) { Column { Text("Your count: ${count.value}") ElevatedButton(onClick = { count.value += 1 }) { Text("Add 1") } } } } This is working as expected. count is state without remember, that makes it resetting… Read More Jetpack Compose: Surface makes state is persisting without remember

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 works, but I can’t figure out how to make the variable selectedView updateable. This would work… Read More What is the syntax to make a callback function variable mutable in Jetpack Compose?

MutableStateFlow not recompose when list is clear in jetpack compose

I have one MutableStateFlow which is kind of emptyList. When I add the item my view is recomposed without any problem. Now I want to recompose view when list is clear. I tried some piece of code but nothing happens. PairViewModel class PairViewModel : BaseViewModel() { val scanLowEnergyDevices by lazy { MutableStateFlow(emptyList<ScanResult>()) } fun addDevices(result:… Read More MutableStateFlow not recompose when list is clear in jetpack compose

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, defStyleAttr) { private val hide = mutableStateOf(false) var hideBars: Boolean get() = hide.value set(value) { hide.value = value } @Composable override fun Content() {… Read More Android Jetpack Compose rememberSystemUiController() doesn't observe mutableStateOf()