fromJson static method
Null when the widget type this build does not know. A server that grows a widget kind must not break a dashboard that renders the rest — the same forward-compatibility rule the schema parser follows.
Implementation
static ChartWidgetData fromJson(Map<String, dynamic> json) {
final rawLabels = json['labels'];
final rawDatasets = json['datasets'];
return ChartWidgetData(
heading: json['heading'] is String ? json['heading'] as String : null,
description: json['description'] is String
? json['description'] as String
: null,
chartType: json['chartType'] is String
? json['chartType'] as String
: 'line',
labels: [
if (rawLabels is List)
for (final label in rawLabels)
if (label is String) label,
],
datasets: [
if (rawDatasets is List)
for (final entry in rawDatasets)
if (entry is Map<String, dynamic>)
if (ChartDataset.fromJson(entry) case final dataset?) dataset,
],
);
}