fieldState
fun <Value> fieldState(key: String? = null, builder: PreviewLabScope.FieldBuilderScope.() -> MutablePreviewLabField<Value>): MutableState<Value>
Creates a mutable field that can be used to store and observe state in the Preview Lab. Use fieldValue if you do not need to update the status. This is useful, for example, for a TextField, where you want to use both the state value and its updates. For example, use the following.
PreviewLab {
var myText by fieldState { StringField("myText", "initialValue") }
TextField(
value = myText,
onValueChange = { myText = it },
)
}Content copied to clipboard