Ama*_*ary 2 checkboxlist flutter
我正在使用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,
)
Run Code Online (Sandbox Code Playgroud)
我可以在选中复选框后更改其颜色,但在选中之前无法更改其颜色而不是默认值。怎么做?
尝试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
),
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5537 次 |
| 最近记录: |