Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 101d889

Browse files
jamesderlincbbraun
authored andcommitted
Clean up violations of Dart lint prefer_collection_literals
Use collection literals where possible. Because a lot of this code explicitly uses `LinkedHashMap` to indicate that order is important, add appropriate `// ignore` comments until https://github.com/dart-lang/linter/issues/1649 is addressed. PiperOrigin-RevId: 360552809
1 parent bcf2aef commit 101d889

11 files changed

+16
-6
lines changed

charts_common/lib/src/chart/bar/bar_lane_renderer.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
6363
/// as the data was given to the chart. For the case where both grouping and
6464
/// stacking are disabled, this means that bars for data later in the series
6565
/// will be drawn "on top of" bars earlier in the series.
66+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
6667
final _barLaneStackMap = LinkedHashMap<String, List<AnimatedBar<D>>>();
6768

6869
/// Store a map of flags to track whether all measure values for a given
6970
/// domain value are null, for every series on the chart.
71+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
7072
final _allMeasuresForDomainNullMap = LinkedHashMap<D, bool>();
7173

7274
factory BarLaneRenderer({BarLaneRendererConfig config, String rendererId}) {
@@ -89,7 +91,7 @@ class BarLaneRenderer<D> extends BarRenderer<D> {
8991
final domainFn = series.domainFn;
9092
final measureFn = series.rawMeasureFn;
9193

92-
final domainValues = Set<D>();
94+
final domainValues = <D>{};
9395

9496
for (var barIndex = 0; barIndex < series.data.length; barIndex++) {
9597
final domain = domainFn(barIndex);

charts_common/lib/src/chart/bar/base_bar_renderer.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
8888
/// as the data was given to the chart. For the case where both grouping and
8989
/// stacking are disabled, this means that bars for data later in the series
9090
/// will be drawn "on top of" bars earlier in the series.
91+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
9192
final _barStackMap = LinkedHashMap<String, List<B>>();
9293

9394
// Store a list of bar stacks that exist in the series data.
@@ -98,6 +99,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
9899
final _currentKeys = <String>[];
99100

100101
/// Stores a list of stack keys for each group key.
102+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
101103
final _currentGroupsStackKeys = LinkedHashMap<D, Set<String>>();
102104

103105
/// Optimization for getNearest to avoid scanning all data if possible.
@@ -462,7 +464,7 @@ abstract class BaseBarRenderer<D, R extends BaseBarRendererElement,
462464
// Store off stack keys for each bar group to help getNearest identify
463465
// groups of stacks.
464466
_currentGroupsStackKeys
465-
.putIfAbsent(domainValue, () => Set<String>())
467+
.putIfAbsent(domainValue, () => <String>{})
466468
.add(barStackMapKey);
467469

468470
// Get the barElement we are going to setup.

charts_common/lib/src/chart/cartesian/cartesian_chart.dart

+1
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ abstract class CartesianChart<D> extends BaseChart<D> {
293293
removeView(axis);
294294
});
295295

296+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
296297
_disjointMeasureAxes = LinkedHashMap<String, NumericAxis>();
297298
if (_disjointMeasureAxesSpec != null) {
298299
_disjointMeasureAxesSpec.forEach((String axisId, AxisSpec axisSpec) {

charts_common/lib/src/chart/common/base_chart.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ abstract class BaseChart<D> {
6666
/// initial draw cycle (e.g. a [Legend] may hide some series).
6767
List<MutableSeries<D>> _currentSeriesList;
6868

69-
Set<String> _usingRenderers = Set<String>();
69+
Set<String> _usingRenderers = <String>{};
7070
Map<String, List<MutableSeries<D>>> _rendererToSeriesList;
7171

7272
final _seriesRenderers = <String, SeriesRenderer<D>>{};
@@ -585,7 +585,7 @@ abstract class BaseChart<D> {
585585
Map<String, List<MutableSeries<D>>> rendererToSeriesList = {};
586586

587587
var unusedRenderers = _usingRenderers;
588-
_usingRenderers = Set<String>();
588+
_usingRenderers = <String>{};
589589

590590
// Build map of rendererIds to SeriesLists.
591591
seriesList.forEach((MutableSeries<D> series) {

charts_common/lib/src/chart/common/behavior/legend/series_legend.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import 'per_series_legend_entry_generator.dart';
3131
/// By default this behavior creates a legend entry per series.
3232
class SeriesLegend<D> extends Legend<D> {
3333
/// List of currently hidden series, by ID.
34-
final _hiddenSeriesList = Set<String>();
34+
final _hiddenSeriesList = <String>{};
3535

3636
/// List of series IDs that should be hidden by default.
3737
List<String> _defaultHiddenSeries;

charts_common/lib/src/chart/common/behavior/line_point_highlighter.dart

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class LinePointHighlighter<D> implements ChartBehavior<D> {
106106
///
107107
/// [LinkedHashMap] is used to render the series on the canvas in the same
108108
/// order as the data was provided by the selection model.
109+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
109110
var _seriesPointMap = LinkedHashMap<String, _AnimatedPoint<D>>();
110111

111112
// Store a list of points that exist in the series data.

charts_common/lib/src/chart/common/behavior/range_annotation.dart

+1
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class RangeAnnotation<D> implements ChartBehavior<D> {
100100
///
101101
/// [LinkedHashMap] is used to render the series on the canvas in the same
102102
/// order as the data was given to the chart.
103+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
103104
final _annotationMap = LinkedHashMap<String, _AnimatedAnnotation<D>>();
104105

105106
// Store a list of annotations that exist in the current annotation list.

charts_common/lib/src/chart/line/line_renderer.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class LineRenderer<D> extends BaseCartesianRenderer<D> {
135135
final styleSegments = <_LineRendererElement<D>>[];
136136
var styleSegmentsIndex = 0;
137137

138-
final usedKeys = Set<String>();
138+
final usedKeys = <String>{};
139139

140140
// Configure style segments for each series.
141141
String previousSegmentKey;

charts_common/lib/src/chart/pie/arc_renderer.dart

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ArcRenderer<D> extends BaseSeriesRenderer<D> {
4949
///
5050
/// [LinkedHashMap] is used to render the series on the canvas in the same
5151
/// order as the data was given to the chart.
52+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
5253
final _seriesArcMap = LinkedHashMap<String, _AnimatedArcList<D>>();
5354

5455
// Store a list of arcs that exist in the series data.

charts_common/lib/src/chart/scatter_plot/point_renderer.dart

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class PointRenderer<D> extends BaseCartesianRenderer<D> {
7575
/// [LinkedHashMap] is used to render the series on the canvas in the same
7676
/// order as the data was given to the chart.
7777
@protected
78+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
7879
var seriesPointMap = LinkedHashMap<String, List<AnimatedPoint<D>>>();
7980

8081
// Store a list of lines that exist in the series data.

charts_common/lib/src/chart/scatter_plot/symbol_annotation_renderer.dart

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SymbolAnnotationRenderer<D> extends PointRenderer<D>
5959

6060
var _currentHeight = 0;
6161

62+
// ignore: prefer_collection_literals, https://github.com/dart-lang/linter/issues/1649
6263
final _seriesInfo = LinkedHashMap<String, _SeriesInfo<D>>();
6364

6465
SymbolAnnotationRenderer(

0 commit comments

Comments
 (0)