onCreateShader property

CartesianShaderCallback? onCreateShader

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(
             <Color>[Colors.yellow, Colors.lightBlue, Colors.brown],


final CartesianShaderCallback? onCreateShader;