mirror of
https://github.com/flutter/samples.git
synced 2026-05-20 22:17:17 +00:00
web/charts: Migrate to null safety (#921)
This commit is contained in:
@@ -23,10 +23,10 @@ import 'package:flutter/material.dart';
|
||||
/// A series of [ChartTitle] behaviors are used to render titles, one per
|
||||
/// margin.
|
||||
class ChartTitleLine extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, num>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const ChartTitleLine(this.seriesList, {this.animate, Key key})
|
||||
const ChartTitleLine(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [LineChart] with sample data and no transition.
|
||||
|
||||
@@ -48,10 +48,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class InitialHintAnimation extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const InitialHintAnimation(this.seriesList, {this.animate, Key key})
|
||||
const InitialHintAnimation(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [BarChart] with sample data and no transition.
|
||||
|
||||
@@ -31,10 +31,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class InitialSelection extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const InitialSelection(this.seriesList, {this.animate, Key key})
|
||||
const InitialSelection(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [BarChart] with initial selection behavior.
|
||||
|
||||
@@ -24,10 +24,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:charts_flutter/flutter.dart' as charts;
|
||||
|
||||
class PercentOfDomainBarChart extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const PercentOfDomainBarChart(this.seriesList, {this.animate, Key key})
|
||||
const PercentOfDomainBarChart(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a stacked [BarChart] with sample data and no transition.
|
||||
|
||||
@@ -25,11 +25,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:charts_flutter/flutter.dart' as charts;
|
||||
|
||||
class PercentOfDomainByCategoryBarChart extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const PercentOfDomainByCategoryBarChart(this.seriesList,
|
||||
{this.animate, Key key})
|
||||
{this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
factory PercentOfDomainByCategoryBarChart.withSampleData() {
|
||||
|
||||
@@ -22,10 +22,10 @@ import 'package:flutter/material.dart';
|
||||
import 'package:charts_flutter/flutter.dart' as charts;
|
||||
|
||||
class PercentOfSeriesBarChart extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const PercentOfSeriesBarChart(this.seriesList, {this.animate, Key key})
|
||||
const PercentOfSeriesBarChart(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a stacked [BarChart] with sample data and no transition.
|
||||
|
||||
@@ -19,10 +19,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SelectionBarHighlight extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SelectionBarHighlight(this.seriesList, {this.animate, Key key})
|
||||
const SelectionBarHighlight(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [BarChart] with sample data and no transition.
|
||||
|
||||
@@ -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'));
|
||||
});
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SelectionLineHighlight extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, num>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SelectionLineHighlight(this.seriesList, {this.animate, Key key})
|
||||
const SelectionLineHighlight(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [LineChart] with sample data and no transition.
|
||||
|
||||
@@ -19,11 +19,11 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SelectionLineHighlightCustomShape extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, num>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SelectionLineHighlightCustomShape(this.seriesList,
|
||||
{this.animate, Key key})
|
||||
{this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [LineChart] with sample data and no transition.
|
||||
|
||||
@@ -38,10 +38,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SelectionScatterPlotHighlight extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, num>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SelectionScatterPlotHighlight(this.seriesList, {this.animate, Key key})
|
||||
const SelectionScatterPlotHighlight(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [ScatterPlotChart] with sample data and no transition.
|
||||
@@ -225,9 +225,9 @@ class LinearSales {
|
||||
final int year;
|
||||
final int sales;
|
||||
final double radius;
|
||||
final String shape;
|
||||
final charts.Color fillColor;
|
||||
final double strokeWidth;
|
||||
final String? shape;
|
||||
final charts.Color? fillColor;
|
||||
final double? strokeWidth;
|
||||
|
||||
LinearSales(this.year, this.sales, this.radius, this.shape, this.fillColor,
|
||||
this.strokeWidth);
|
||||
|
||||
@@ -29,10 +29,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SelectionUserManaged extends StatefulWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SelectionUserManaged(this.seriesList, {this.animate, Key key})
|
||||
const SelectionUserManaged(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [BarChart] with sample data and no transition.
|
||||
|
||||
@@ -33,10 +33,10 @@ import 'package:flutter/scheduler.dart';
|
||||
/// [Slider.moveSliderToDomain] can be called to programmatically position the
|
||||
/// slider. This is useful for synchronizing the slider with external elements.
|
||||
class SliderLine extends StatefulWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, num>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SliderLine(this.seriesList, {this.animate, Key key}) : super(key: key);
|
||||
const SliderLine(this.seriesList, {this.animate, Key? key}) : super(key: key);
|
||||
|
||||
/// Creates a [LineChart] with sample data and no transition.
|
||||
factory SliderLine.withSampleData() {
|
||||
@@ -103,9 +103,9 @@ class SliderLine extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _SliderCallbackState extends State<SliderLine> {
|
||||
num _sliderDomainValue;
|
||||
String _sliderDragState;
|
||||
Point<int> _sliderPosition;
|
||||
num? _sliderDomainValue;
|
||||
String? _sliderDragState;
|
||||
Point<int>? _sliderPosition;
|
||||
|
||||
// Handles callbacks when the user drags the slider.
|
||||
_onSliderChange(Point<int> point, dynamic domain, String roleId,
|
||||
@@ -119,7 +119,7 @@ class _SliderCallbackState extends State<SliderLine> {
|
||||
});
|
||||
}
|
||||
|
||||
SchedulerBinding.instance.addPostFrameCallback(rebuild);
|
||||
SchedulerBinding.instance!.addPostFrameCallback(rebuild);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -175,7 +175,7 @@ class _SliderCallbackState extends State<SliderLine> {
|
||||
children.add(Padding(
|
||||
padding: const EdgeInsets.only(top: 5.0),
|
||||
child: Text(
|
||||
'Slider position: ${_sliderPosition.x}, ${_sliderPosition.y}')));
|
||||
'Slider position: ${_sliderPosition!.x}, ${_sliderPosition!.y}')));
|
||||
}
|
||||
if (_sliderDragState != null) {
|
||||
children.add(Padding(
|
||||
|
||||
@@ -22,10 +22,10 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SlidingViewportOnSelection extends StatelessWidget {
|
||||
final List<charts.Series> seriesList;
|
||||
final bool animate;
|
||||
final List<charts.Series<dynamic, String>> seriesList;
|
||||
final bool? animate;
|
||||
|
||||
const SlidingViewportOnSelection(this.seriesList, {this.animate, Key key})
|
||||
const SlidingViewportOnSelection(this.seriesList, {this.animate, Key? key})
|
||||
: super(key: key);
|
||||
|
||||
/// Creates a [BarChart] with sample data and no transition.
|
||||
|
||||
Reference in New Issue
Block a user