key property Null safety

ValueKey<String>? key
final, inherited

Key to identify a series in a collection.

On specifying ValueKey as the series key, existing series index can be changed in the series collection without losing its state.

When a new series is added dynamically to the collection, existing series index will be changed. On that case, the existing series and its state will be linked based on its chart type and this key value.

Defaults to null.

Widget build(BuildContext context) {
   return Container(
       child: SfFunnelChart(
           series: FunnelSeries<SalesData, num>(
                     key: const ValueKey<String>('funnel_series_key'),
                ),
       ));
}

Implementation

///

///On specifying [ValueKey] as the series [key], existing series index can be
/// changed in the series collection without losing its state.

///

///When a new series is added dynamically to the collection, existing series index will be changed. On that case,

/// the existing series and its state will be linked based on its chart type and this key value.

///

///Defaults to `null`.

///
///```dart
///Widget build(BuildContext context) {
///    return Container(
///        child: SfFunnelChart(
///            series: FunnelSeries<SalesData, num>(
///                      key: const ValueKey<String>('funnel_series_key'),
///                 ),
///        ));
///}
///```
final ValueKey<String>? key;