How to change border color of checkbox in flutter / dart

You Can Use Side Property...

side: BorderSide(color: Color(0xff585858)),


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).

is case you wanna define app-wide theme for your checkboxes you can do this:

MaterialApp(
   ...
  theme:ThemeData(
    checkboxTheme: CheckboxThemeData(
      fillColor: MaterialStateColor.resolveWith(
        (states) {
          if (states.contains(MaterialState.selected)) {
           return Colors.purple // the color when checkbox is selected;
            }
         return Colors.white //the color when checkbox is unselected;
         },
    ),
   ),
  ),
 )

it is a good practice to define app-wide theme for your app to avoid code duplication and ensure consistency it also provides better maintenance. enjoy coding:)

Tags:

Dart

Flutter