gpt4 book ai didi

flutter - 如何在 Flutter 中实现 CheckBox?

转载 作者:IT王子 更新时间:2023-10-29 07:07:40 26 4
gpt4 key购买 nike

这里我提到了我的复选框代码。我是 Flutter 的新手,所以我必须实现它以实现记住我的功能。

代码:

 Container(
padding: EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
new Checkbox(value: checkBoxValue,
activeColor: Colors.green,
onChanged:(bool newValue){
setState(() {
checkBoxValue = newValue;
});
Text('Remember me');
}),
],
),
);

最佳答案

如果您需要带有标签的Checkbox,那么您可以使用CheckboxListTile:

CheckboxListTile(
title: Text("title text"),
value: checkedValue,
onChanged: (newValue) {
setState(() {
checkedValue = newValue;
});
},
controlAffinity: ListTileControlAffinity.leading, // <-- leading Checkbox
)

关于flutter - 如何在 Flutter 中实现 CheckBox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52814039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com