I am using the CheckBoxListTile
like this,
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,
)
I could change the color of the checkbox after it is checked, but I cannot change its color before it is checked rather than its default value. How to do that?
try wrap CheckBoxListTile
with Theme widget and choose color at unselectedWidgetColor
properties.
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
),
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.