initialIsVisible property

bool initialIsVisible
final

Visibility of the series, which applies only during load time.

Default to true.

Widget build(BuildContext context) {
  return SfCartesianChart(
    series: <CartesianSeries<SalesData, num>>[
      LineSeries<SalesData, num>(
        initialIsVisible: false
      ),
    ],
  );
}

Use the onRendererCreated callback, as shown in the code below, to update the visibility dynamically.

ChartSeriesController? controller;

@override
Widget build(BuildContext context) {
  return Scaffold(
    body: Column(
      children: [
        SfCartesianChart(
          series: <CartesianSeries<SalesData, num>>[
            LineSeries<SalesData, num>(
              dataSource: data,
              xValueMapper: (SalesData sales, _) => sales.year,
              yValueMapper: (SalesData sales, _) => sales.sales,
              onRendererCreated: (ChartSeriesController seriesController) {
                controller = seriesController;
              },
            ),
          ],
        ),
        TextButton(
          onPressed: () {
            if (controller != null) {
              controller!.isVisible = true;
            }
          },
          child: const Text('Update Series Visibility'),
        ),
      ],
    ),
  );
}

Implementation

final bool initialIsVisible;