key property
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 SfCartesianChart(
series: <LineSeries<SalesData, num>>[
LineSeries<SalesData, num>(
key: const ValueKey<String>('line_series_key'),
),
],
);
}
Implementation
final ValueKey<String>? key;