https://kotlinlang.org logo
m

myanmarking

09/30/2021, 12:08 PM
Is there any recommended practice to expose some composable internal state, but keeping it updatable only internally? For instance, i have this inside the composable:
Copy code
val hasError by remember(textFieldValue.value) {
    derivedStateOf {
        textFieldValue.value.text.isNotEmpty() && isInputValid(textFieldValue.value.text).not()
    }
}
I want the caller code to access this value, but i don’t want to change it outside
a

Albert Chang

09/30/2021, 12:18 PM
You can create a custom state class similar to
LazyListState
,
BottomSheetState
, etc.
m

myanmarking

09/30/2021, 12:19 PM
ok. ill check. thanks
2 Views