Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the check icon color in flutter filterChip

Tags:

flutter

I need a way to change the check (✔) color to white. How do I achieve thatscrennshot of the current result

like image 241
TheLetch Avatar asked Oct 28 '25 16:10

TheLetch


2 Answers

You can change the color of the checkmark by using checkMarkColor property

FilterChip(
        label: Text('Pizza'),
        shape: StadiumBorder(side: BorderSide()),
        checkmarkColor: Colors.red,
        backgroundColor: Colors.transparent,
      ),
like image 100
Ken Verganio Avatar answered Oct 31 '25 12:10

Ken Verganio


Black or white checkmark

You can change the color to either black or white based on a light or dark theme. You can change the theme globally or wrap the specific widget within a Theme widget.

Theme(
  data: ThemeData(
    brightness: Brightness.dark
  ), // or shorthand => ThemeData.dark()
  child: FilterChip(
    label: Text('My chip'),
    onSelected: (value) {
      // ...
    },
  ),
);

Other colors

There is currently no way to change the color of the checkmark in the FilterChip provided by the Material package to an arbitrary color. The way the checkmark is drawn can be found in the source code for the Chip classes here.

For future reference, this is the part of code that draws the checkmark:

void _paintCheck(Canvas canvas, Offset origin, double size) {
    Color paintColor;
    switch (theme.brightness) {
      case Brightness.light:
        paintColor = theme.showAvatar ? Colors.white : Colors.black.withAlpha(_kCheckmarkAlpha);
        break;
      case Brightness.dark:
        paintColor = theme.showAvatar ? Colors.black : Colors.white.withAlpha(_kCheckmarkAlpha);
        break;
    }
    ...

So it is only able to show either as black or white right now. If you want it colored, you'll have to resort to a custom widget.

You could also chime in on the already opened issue on Flutters Github project.

like image 31
Tim Klingeleers Avatar answered Oct 31 '25 12:10

Tim Klingeleers