gpt4 book ai didi

flutter - 如何在 flutter 中更改 checkBoxListTile 中的复选框颜色?

转载 作者:行者123 更新时间:2023-12-02 02:37:47 25 4
gpt4 key购买 nike

我正在像这样使用 CheckBoxListTile

CheckboxListTile(
title: Text(
ourAllnotes[i].note,
style: TextStyle(color: Colors.white),
),
value: false,
onChanged: (bool value) {},
activeColor: Colors.orange,
checkColor: Colors.white,
controlAffinity: ListTileControlAffinity.leading,
)

我可以在选中后更改复选框的颜色,但我无法在选中之前更改其颜色而不是其默认值。如何做到这一点?

最佳答案

尝试用 Theme 小部件包装 CheckBoxListTile 并在 unselectedWidgetColor 属性中选择颜色。

  Theme(
data: ThemeData(unselectedWidgetColor: Colors.white),
child: CheckboxListTile(
checkColor: Colors.white,

title: Text(
"show password",
style: TextStyle(
fontSize: 12, color: Colors.white, letterSpacing: 2),
),
value: checkboxflag,
onChanged: (newValue) {
setState(() {
if (newValue) {
checkboxflag = newValue;
_obscureText = false;
} else {
checkboxflag = newValue;
_obscureText = true;
}
});
},
controlAffinity:
ListTileControlAffinity.leading, // <-- leading Checkbox
),
)

关于flutter - 如何在 flutter 中更改 checkBoxListTile 中的复选框颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64059629/

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