'How to change the default color palette for charts in flutter?

I use charts_flutter to create charts. I know how to change the color, but I like to change the color palette. The default palette seems to be "blue". For example in a pie chart, charts_flutter uses different shades of blue. I like to use deeporange as the default palette for all kind of charts. Is there a way to change it?



Solution 1:[1]

I know this question is bit old, but I just had the same problem and found a solution.

    int numberOfColorsYouWant = 3;
    ...
    colorFn: (_, index){
      return charts.MaterialPalette.green.makeShades(numberOfColorsYouWant)[index];
    },

Solution 2:[2]

Not currently using it but just looked rapidly at the code and saw this:

colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
fillColorFn: (_, __) =>
        charts.MaterialPalette.blue.shadeDefault.lighter,

maybe you can change them changing this parameter.

This is the url where I found them : https://google.github.io/charts/flutter/example/bar_charts/stacked_fill_color

Solution 3:[3]

If you want different colors instead of shades you can use:

var palettes = charts.MaterialPalette.getOrderedPalettes(<number of palettes>);

var seriesColor = palettes.elementAt(i).shadeDefault; 

Solution 4:[4]

Hello you can set your custom color like this

 charts.ColorUtil.fromDartColor(Colors.deepPurple) 

or

 charts.ColorUtil.fromDartColor(Color(0xff4EB200))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Flomp
Solution 2 Cristian Bregant
Solution 3 Alberto L. Bonfiglio
Solution 4 Grigoris Kritopoulos