Slide 25
Slide 25 text
状態を持ったコンポーネントの作成
@Model
data class CounterModel(
var count: Int
)
@Composable
fun CounterWidget() {
Column {
val counter by +state { CounterModel(0) }
Text(
text = "Count: ${counter.count}",
style = +themeTextStyle { h5 }
)
Button(
text = "+",
onClick = { counter.count++ }
)
}
}
● プリミティブ型、String型の場合は
val counter = +state { 0 }
で呼び出し可能