onCreateShader property

CircularShaderCallback? onCreateShader
final

Fills the data points with the gradient and image shaders.

The data points of pie, doughnut and radial bar charts can be filled with gradient (linear, radial and sweep gradient) and image shaders.

All the data points are together considered as a single segment and the shader is applied commonly.

Defaults to null.

final List<Color> colors = <Color>[
  const Color.fromRGBO(75, 135, 185, 1),
  const Color.fromRGBO(192, 108, 132, 1),
  const Color.fromRGBO(246, 114, 128, 1),
  const Color.fromRGBO(248, 177, 149, 1),
  const Color.fromRGBO(116, 180, 155, 1)
];
final List<double> stops = <double>[
   0.2,
   0.4,
   0.6,
   0.8,
   1,
];
Widget build(BuildContext context) {
   return Container(
       child: SfCircularChart(
           onCreateShader: (ChartShaderDetails chartShaderDetails) {
                return ui.Gradient.linear(
                  chartShaderDetails.outerRect.topRight,
                  chartShaderDetails.outerRect.centerLeft,
                  colors,
                  stops);
              },
       )
   );
}

Implementation

final CircularShaderCallback? onCreateShader;