I need to change check mark color of the checkbox in the flutter and there is no parameter is given to change color in Checkbox.
Checkbox( value: isCheck, activeColor: Colors.grey, onChanged: (bool value) { setState(() { isCheck = value;}); })
dart class code
const Checkbox({ Key key, @required this.value, this.tristate = false, @required this.onChanged, this.activeColor, this.materialTapTargetSize, }) : assert(tristate != null), assert(tristate || value != null), super(key: key);
Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.
Checkbox(value: false, tristate: false, onChanged: () {}); ↓ Theme( data: ThemeData(unselectedWidgetColor: Colors. red), child: Checkbox(value: false, tristate: false, onChanged: (bool value) {})); No onChanged, then the border will be grey(disabled). Glad, I was able to help!
To change color of a checkbox:
When inactive (border color):
Theme( data: Theme.of(context).copyWith( unselectedWidgetColor: Colors.white, ), child: Checkbox(...), )
When checked (icon color):
Checkbox( checkColor: Colors.red, ... )
When active (checked):
Checkbox( activeColor: Colors.amberAccent, ... )
Full Code Sample:
Theme( data: Theme.of(context).copyWith( unselectedWidgetColor: Colors.white, ), child: Checkbox( checkColor: Colors.red, activeColor: Colors.amberAccent, value: _terms, onChanged: (bool value) { setState(() { _terms = value; }); }, ), )
Right now I am Using -
Flutter (Channel dev, v1.2.2,)
Option to change the Checkmark Color is not present on stable channel.
Checkbox( value: isCheck, checkColor: Colors.yellowAccent, // color of tick Mark activeColor: Colors.grey, onChanged: (bool value) { setState(() { isCheck = value; }); }),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With