1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-09 22:38:42 +00:00

web/charts: Migrate to null safety (#921)

This commit is contained in:
Brett Morgan
2021-10-08 16:39:37 +11:00
committed by GitHub
parent d14e79b833
commit 8932e60976
106 changed files with 355 additions and 346 deletions

View File

@@ -33,10 +33,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
import 'package:flutter/material.dart';
class SelectionCallbackExample extends StatefulWidget {
final List<charts.Series> seriesList;
final bool animate;
final List<charts.Series<dynamic, DateTime>> seriesList;
final bool? animate;
const SelectionCallbackExample(this.seriesList, {this.animate, Key key})
const SelectionCallbackExample(this.seriesList, {this.animate, Key? key})
: super(key: key);
/// Creates a [charts.TimeSeriesChart] with sample data and no transition.
@@ -130,8 +130,8 @@ class SelectionCallbackExample extends StatefulWidget {
}
class _SelectionCallbackState extends State<SelectionCallbackExample> {
DateTime _time;
Map<String, num> _measures;
DateTime? _time;
Map<String?, num?>? _measures;
// Listens to the underlying selection changes, and updates the information
// relevant to building the primitive legend like information under the
@@ -139,8 +139,8 @@ class _SelectionCallbackState extends State<SelectionCallbackExample> {
_onSelectionChanged(charts.SelectionModel model) {
final selectedDatum = model.selectedDatum;
DateTime time;
final measures = <String, num>{};
DateTime? time;
final measures = <String?, num?>{};
// We get the model that updated with a list of [SeriesDatum] which is
// simply a pair of series & datum.
@@ -185,7 +185,7 @@ class _SelectionCallbackState extends State<SelectionCallbackExample> {
padding: const EdgeInsets.only(top: 5.0),
child: Text(_time.toString())));
}
_measures?.forEach((String series, num value) {
_measures?.forEach((String? series, num? value) {
children.add(Text('$series: $value'));
});