Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change checked mark color of checkbox in flutter

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); 
like image 753
Farhana Naaz Ansari Avatar asked Feb 22 '19 06:02

Farhana Naaz Ansari


People also ask

How do I change the color of a checkbox box?

Setting the android:buttonTint="@color/mybrown" is an easy way to change the box color.

How do I give a checkbox a border color in flutter?

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!


2 Answers

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;           });         },       ),     ) 
like image 80
Pasan Randula Eramusugoda Avatar answered Sep 21 '22 00:09

Pasan Randula Eramusugoda


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;             });           }), 
like image 26
anmol.majhail Avatar answered Sep 21 '22 00:09

anmol.majhail