onCreateShader property

CartesianShaderCallback? 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.

Widget build(BuildContext context) {
  return SfCartesianChart(
    series: <BarSeries<SalesData, num>>[
       BarSeries<SalesData, num>(
         // To use the gradient for shader rendering,
         // `import 'dart:ui' as ui;` this file should be imported.
         onCreateShader: (ShaderDetails details) {
           return ui.Gradient.linear(
             details.rect.topRight,
             details.rect.bottomLeft,
             <Color>[Colors.yellow, Colors.lightBlue, Colors.brown],
             <double>[0.2,0.6,1]
           );
         },
       ),
    ]
  );
}

Implementation

final CartesianShaderCallback? onCreateShader;