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

GitHub Sync (nullability support sync) #646

Merged
merged 56 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4da4612
Remove unnecessary (and harmful) explicit types
jamesderlin Mar 12, 2021
a008174
Fix some forEach usage
jamesderlin Mar 12, 2021
77ab8a3
Use .of() instead of .from() when possible
jamesderlin Mar 12, 2021
78f2bc4
Fix violations of implicit-dynamic (part 1)
jamesderlin Mar 12, 2021
9b63878
charts_common: Fix violations of implicit-dynamic (part 2)
jamesderlin Mar 13, 2021
b9a1d2d
Fix violations of implicit-dynamic (part 3)
jamesderlin Mar 13, 2021
89f1735
Fix violations of implicit-dynamic (part 4)
jamesderlin Mar 13, 2021
e0d1465
Fix violations of implicit-dynamic (part 5)
jamesderlin Mar 13, 2021
8e40fda
Fix violations of implicit-dynamic (part 6)
jamesderlin Mar 13, 2021
698c541
Fix violations of implicit-dynamic (part 7)
jamesderlin Mar 13, 2021
2f4e4d1
Clean up implicit downcasts
jamesderlin Mar 17, 2021
bc62922
Clean up violations of Dart lint omit_local_variable_types
jamesderlin Mar 17, 2021
2277869
Remove unnecessary null-aware operators when computing hash codes
jamesderlin Mar 17, 2021
a44789c
Simplify and strengthen TimeStepper assertions
jamesderlin Mar 17, 2021
11999c1
Make A11yExploreBehavior(exploreModeTrigger: null) use the default
jamesderlin Mar 18, 2021
23a7550
Remove broken NumericTickProvider.getTicks caching
jamesderlin Mar 18, 2021
35d7942
Expose BasicDateTimeTickFormatterSpec in charts_flutter
a-googler Mar 23, 2021
4ecc071
Internal changes
a-googler Mar 30, 2021
33162a7
Fix more analysis errors
jamesderlin Apr 7, 2021
88d8a56
Make better use of string interpolation
jamesderlin Apr 7, 2021
741006c
Make more named parameters required (and make some not required)
jamesderlin Apr 7, 2021
5e7553b
Prefer initializer lists to constructor bodies
jamesderlin Apr 7, 2021
08a7ab6
Add and use construction parameters instead of mutating members
jamesderlin Apr 7, 2021
855f60d
Add a NullablePoint class and use it instead of Point<double>
jamesderlin Apr 7, 2021
06e2a04
Make better use of null-aware operators
jamesderlin Apr 9, 2021
d3585bd
Explicitly handle null values in more places
jamesderlin Apr 9, 2021
57a0403
Miscellaneous, non-trivial changes
jamesderlin Apr 9, 2021
78d6f9c
Disable null-safety for tests
jamesderlin Apr 9, 2021
7b6af6d
Mechanical null migration changes
jamesderlin Apr 9, 2021
b8dba87
Roll back null safety migration change
jamesderlin Apr 9, 2021
475d708
Reapply null safety migration change
jamesderlin Apr 13, 2021
ac32922
Post-null-migration cleanup
jamesderlin Apr 13, 2021
70078b6
Internal changes
nolankelly Apr 14, 2021
df9a9f6
Fix build warnings in charts_common
a-googler Apr 27, 2021
556da0b
Automated g4 rollback of changelist 370588847.
a-googler Apr 27, 2021
af03fc2
Automated g4 rollback of changelist 370712865.
a-googler Apr 29, 2021
368877e
Internal changes
a-googler Apr 30, 2021
d45d55b
Internal changes
a-googler May 3, 2021
1fb0f84
Internal changes
a-googler May 4, 2021
3e1da50
Internal changes
nolankelly May 5, 2021
5d43236
Internal changes
a-googler May 6, 2021
0b40f17
Internal changes
a-googler May 18, 2021
84adf34
Internal changes
a-googler May 26, 2021
4f9cdac
Internal changes
a-googler May 26, 2021
4cf719b
Internal changes
a-googler Jun 9, 2021
b39f4dc
Internal changes
a-googler Jun 9, 2021
72eb27d
Migrate deprecated TextTheme API from body1 to bodyText2
a-googler Jun 9, 2021
0e3ea3d
Internal changes
a-googler Jun 14, 2021
324bd58
Internal changes
a-googler Jun 16, 2021
2ac6354
Internal changes
a-googler Jun 17, 2021
c2fab81
Fixed nullability issues in chart classes.
a-googler Jun 18, 2021
39ded09
Migrate //third_party/dart/charts_flutter to null safety.
a-googler Jun 24, 2021
5abbb08
Migrate //third_party/dart/charts_flutter/examples to null safety.
a-googler Jun 25, 2021
4d2dfcf
Bump sdk version for nullability support to hopefully get travis test…
cbbraun Jun 26, 2021
7319397
Fix mockito testing for null safety
cbbraun Jun 30, 2021
8316522
Fixing tests removing some mockito use
cbbraun Jun 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions charts_common/charts_common.gwsq
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
send_cls_to('dart-charts-team+reviews');
send_cls_to('dart-charts-team');

define Main {
reassign_to_list(from_owners_file('third_party/dart/charts_common/OWNERS'));
}
12 changes: 12 additions & 0 deletions charts_common/lib/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export 'src/chart/bar/bar_renderer_decorator.dart' show BarRendererDecorator;
export 'src/chart/bar/bar_target_line_renderer.dart' show BarTargetLineRenderer;
export 'src/chart/bar/bar_target_line_renderer_config.dart'
show BarTargetLineRendererConfig;
export 'src/chart/bar/base_bar_renderer.dart'
show barGroupIndexKey, barGroupCountKey, barGroupWeightKey;
export 'src/chart/bar/base_bar_renderer_config.dart'
show BarGroupingType, BaseBarRendererConfig;
export 'src/chart/cartesian/axis/axis.dart'
Expand All @@ -38,6 +40,7 @@ export 'src/chart/cartesian/axis/axis.dart'
measureAxisIdKey,
measureAxisKey,
Axis,
ImmutableAxis,
AxisOrientation,
NumericAxis,
OrdinalAxis,
Expand Down Expand Up @@ -179,6 +182,8 @@ export 'src/chart/common/behavior/slider/slider.dart'
SliderListenerDragState,
SliderStyle;
export 'src/chart/common/behavior/sliding_viewport.dart' show SlidingViewport;
export 'src/chart/common/behavior/sunburst_ring_expander.dart'
show SunburstRingExpander;
export 'src/chart/common/behavior/zoom/initial_hint_behavior.dart'
show InitialHintBehavior;
export 'src/chart/common/behavior/zoom/pan_and_zoom_behavior.dart'
Expand Down Expand Up @@ -242,6 +247,12 @@ export 'src/chart/scatter_plot/point_renderer_decorator.dart'
export 'src/chart/scatter_plot/scatter_plot_chart.dart' show ScatterPlotChart;
export 'src/chart/scatter_plot/symbol_annotation_renderer.dart'
show SymbolAnnotationRenderer;
export 'src/chart/sunburst/sunburst_chart.dart' show SunburstChart;
export 'src/chart/sunburst/sunburst_arc_renderer.dart' show SunburstArcRenderer;
export 'src/chart/sunburst/sunburst_arc_renderer_config.dart'
show SunburstArcRendererConfig, SunburstColorStrategy;
export 'src/chart/sunburst/sunburst_arc_label_decorator.dart'
show SunburstArcLabelDecorator;
export 'src/chart/scatter_plot/symbol_annotation_renderer_config.dart'
show SymbolAnnotationRendererConfig;
export 'src/chart/time_series/time_series_chart.dart' show TimeSeriesChart;
Expand All @@ -259,6 +270,7 @@ export 'src/common/gesture_listener.dart' show GestureListener;
export 'src/common/graphics_factory.dart' show GraphicsFactory;
export 'src/common/line_style.dart' show LineStyle;
export 'src/common/material_palette.dart' show MaterialPalette;
export 'src/common/math.dart' show NullablePoint;
export 'src/common/performance.dart' show Performance;
export 'src/common/proxy_gesture_listener.dart' show ProxyGestureListener;
export 'src/common/rtl_spec.dart' show AxisDirection, RTLSpec;
Expand Down
10 changes: 5 additions & 5 deletions charts_common/lib/src/chart/bar/bar_chart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import '../layout/layout_config.dart' show LayoutConfig;

class BarChart extends OrdinalCartesianChart {
BarChart(
{bool vertical,
LayoutConfig layoutConfig,
NumericAxis primaryMeasureAxis,
NumericAxis secondaryMeasureAxis,
LinkedHashMap<String, NumericAxis> disjointMeasureAxes})
{bool? vertical,
LayoutConfig? layoutConfig,
NumericAxis? primaryMeasureAxis,
NumericAxis? secondaryMeasureAxis,
LinkedHashMap<String, NumericAxis>? disjointMeasureAxes})
: super(
vertical: vertical,
layoutConfig: layoutConfig,
Expand Down
49 changes: 30 additions & 19 deletions charts_common/lib/src/chart/bar/bar_error_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,42 +48,50 @@ class BarErrorDecorator<D> extends BarRendererDecorator<D> {
this.outlineColor = _defaultOutlineColor});

@override
void decorate(Iterable<ImmutableBarRendererElement<D>> barElements,
ChartCanvas canvas, GraphicsFactory graphicsFactory,
{Rectangle<num> drawBounds,
double animationPercent,
bool renderingVertically,
bool rtl = false}) {
void decorate(
Iterable<ImmutableBarRendererElement<D>> barElements,
ChartCanvas canvas,
GraphicsFactory graphicsFactory, {
required Rectangle<num> drawBounds,
required double animationPercent,
required bool renderingVertically,
bool rtl = false,
}) {
// Only decorate the bars when animation is at 100%.
if (animationPercent != 1.0) {
return;
}

for (var element in barElements) {
final bounds = element.bounds;
final bounds = element.bounds!;
final datumIndex = element.index;

final measureLowerBoundFn = element.series.measureLowerBoundFn;
final measureUpperBoundFn = element.series.measureUpperBoundFn;
final series = element.series!;

final measureLowerBoundFn = series.measureLowerBoundFn;
final measureUpperBoundFn = series.measureUpperBoundFn;

if (measureLowerBoundFn != null && measureUpperBoundFn != null) {
final measureOffsetFn = element.series.measureOffsetFn;
final measureOffsetFn = series.measureOffsetFn!;
final measureAxis =
element.series.getAttr(measureAxisKey) as ImmutableAxis<num>;
series.getAttr(measureAxisKey) as ImmutableAxis<num>;

if (renderingVertically) {
final startY = measureAxis.getLocation(
measureLowerBoundFn(datumIndex) + measureOffsetFn(datumIndex));
(measureLowerBoundFn(datumIndex) ?? 0) +
measureOffsetFn(datumIndex)!)!;
final endY = measureAxis.getLocation(
measureUpperBoundFn(datumIndex) + measureOffsetFn(datumIndex));
(measureUpperBoundFn(datumIndex) ?? 0) +
measureOffsetFn(datumIndex)!)!;

if (startY != endY) {
final barWidth = bounds.right - bounds.left;
final x = (bounds.left + bounds.right) / 2;
final rectWidth = min(strokeWidthPx + 2 * outlineWidthPx, barWidth);
final rectWidth =
min(strokeWidthPx + 2 * outlineWidthPx, barWidth.toDouble());
final strokeWidth = rectWidth - 2 * outlineWidthPx;
final rectEndpointLength =
min(endpointLengthPx + 2 * outlineWidthPx, barWidth);
min(endpointLengthPx + 2 * outlineWidthPx, barWidth.toDouble());
final endpointLength = rectEndpointLength - 2 * outlineWidthPx;

if (outlineWidthPx > 0) {
Expand Down Expand Up @@ -131,17 +139,20 @@ class BarErrorDecorator<D> extends BarRendererDecorator<D> {
}
} else {
final startX = measureAxis.getLocation(
measureLowerBoundFn(datumIndex) + measureOffsetFn(datumIndex));
(measureLowerBoundFn(datumIndex) ?? 0) +
measureOffsetFn(datumIndex)!)!;
final endX = measureAxis.getLocation(
measureUpperBoundFn(datumIndex) + measureOffsetFn(datumIndex));
(measureUpperBoundFn(datumIndex) ?? 0) +
measureOffsetFn(datumIndex)!)!;

if (startX != endX) {
final barWidth = bounds.bottom - bounds.top;
final y = (bounds.top + bounds.bottom) / 2;
final rectWidth = min(strokeWidthPx + 2 * outlineWidthPx, barWidth);
final rectWidth =
min(strokeWidthPx + 2 * outlineWidthPx, barWidth.toDouble());
final strokeWidth = rectWidth - 2 * outlineWidthPx;
final rectEndpointLength =
min(endpointLengthPx + 2 * outlineWidthPx, barWidth);
min(endpointLengthPx + 2 * outlineWidthPx, barWidth.toDouble());
final endpointLength = rectEndpointLength - 2 * outlineWidthPx;

if (outlineWidthPx > 0) {
Expand Down
65 changes: 33 additions & 32 deletions charts_common/lib/src/chart/bar/bar_label_decorator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import 'dart:math' show Rectangle;

import 'package:meta/meta.dart' show required;

import '../../common/color.dart' show Color;
import '../../common/graphics_factory.dart' show GraphicsFactory;
import '../../common/text_element.dart' show TextDirection, TextElement;
Expand Down Expand Up @@ -54,14 +52,14 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
final BarLabelPlacement labelPlacement;

/// For labels drawn inside the bar, configures label anchor position.
final BarLabelAnchor labelAnchor;
final BarLabelAnchor? labelAnchor;

/// Space before and after the label text.
final int labelPadding;

BarLabelDecorator(
{TextStyleSpec insideLabelStyleSpec,
TextStyleSpec outsideLabelStyleSpec,
{TextStyleSpec? insideLabelStyleSpec,
TextStyleSpec? outsideLabelStyleSpec,
this.labelAnchor,
this.labelPosition = _defaultLabelPosition,
this.labelPlacement = _defaultLabelPlacement,
Expand All @@ -73,9 +71,9 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
@override
void decorate(Iterable<ImmutableBarRendererElement<D>> barElements,
ChartCanvas canvas, GraphicsFactory graphicsFactory,
{@required Rectangle drawBounds,
@required double animationPercent,
@required bool renderingVertically,
{required Rectangle<int> drawBounds,
required double animationPercent,
required bool renderingVertically,
bool rtl = false}) {
// Only decorate the bars when animation is at 100%.
if (animationPercent != 1.0) {
Expand All @@ -95,7 +93,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
Iterable<ImmutableBarRendererElement<D>> barElements,
ChartCanvas canvas,
GraphicsFactory graphicsFactory,
Rectangle drawBounds,
Rectangle<int> drawBounds,
bool rtl) {
// Create [TextStyle] from [TextStyleSpec] to be used by all the elements.
// The [GraphicsFactory] is needed so it can't be created earlier.
Expand All @@ -105,21 +103,21 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
_getTextStyle(graphicsFactory, outsideLabelStyleSpec);

for (var element in barElements) {
final labelFn = element.series.labelAccessorFn;
final measureFn = element.series.measureFn;
final labelFn = element.series!.labelAccessorFn;
final measureFn = element.series!.measureFn;
final datumIndex = element.index;
final label = (labelFn != null) ? labelFn(datumIndex) : null;
final label = labelFn?.call(datumIndex);
final measure = measureFn(datumIndex) ?? 0.0;

// If there are custom styles, use that instead of the default or the
// style defined for the entire decorator.
final datumInsideLabelStyle = _getDatumStyle(
element.series.insideLabelStyleAccessorFn,
element.series!.insideLabelStyleAccessorFn,
datumIndex,
graphicsFactory,
defaultStyle: insideLabelStyle);
final datumOutsideLabelStyle = _getDatumStyle(
element.series.outsideLabelStyleAccessorFn,
element.series!.outsideLabelStyleAccessorFn,
datumIndex,
graphicsFactory,
defaultStyle: outsideLabelStyle);
Expand All @@ -133,7 +131,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
.split(_labelSplitPattern)
.map((labelPart) => graphicsFactory.createTextElement(labelPart));

final bounds = element.bounds;
final bounds = element.bounds!;

// Get space available inside and outside the bar.
final totalPadding = labelPadding * 2;
Expand All @@ -148,7 +146,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
final labelMaxWidth = labelElements
.map(
(labelElement) => labelElement.measurement.horizontalSliceWidth)
.fold(0, (max, current) => max > current ? max : current);
.fold<double>(0, (max, current) => max > current ? max : current);

// Total label height depends on the label element's text style.
final totalLabelHeight = _getTotalLabelHeight(labelElements);
Expand All @@ -174,7 +172,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
var labelsDrawn = 0;
for (var labelElement in labelElements) {
// Calculate the start position of label based on [labelAnchor].
int labelY;
final int labelY;
final labelHeight = labelElement.measurement.verticalSliceWidth.round();
final offsetHeight =
(labelHeight + _defaultMultiLineLabelPadding) * labelsDrawn;
Expand Down Expand Up @@ -227,7 +225,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
Iterable<ImmutableBarRendererElement<D>> barElements,
ChartCanvas canvas,
GraphicsFactory graphicsFactory,
Rectangle drawBounds,
Rectangle<int> drawBounds,
bool rtl) {
// Create [TextStyle] from [TextStyleSpec] to be used by all the elements.
// The [GraphicsFactory] is needed so it can't be created earlier.
Expand All @@ -237,21 +235,21 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
_getTextStyle(graphicsFactory, outsideLabelStyleSpec);

for (var element in barElements) {
final labelFn = element.series.labelAccessorFn;
final measureFn = element.series.measureFn;
final labelFn = element.series!.labelAccessorFn;
final measureFn = element.series!.measureFn;
final datumIndex = element.index;
final label = (labelFn != null) ? labelFn(datumIndex) : null;
final label = labelFn?.call(datumIndex);
final measure = measureFn(datumIndex) ?? 0.0;

// If there are custom styles, use that instead of the default or the
// style defined for the entire decorator.
final datumInsideLabelStyle = _getDatumStyle(
element.series.insideLabelStyleAccessorFn,
element.series!.insideLabelStyleAccessorFn,
datumIndex,
graphicsFactory,
defaultStyle: insideLabelStyle);
final datumOutsideLabelStyle = _getDatumStyle(
element.series.outsideLabelStyleAccessorFn,
element.series!.outsideLabelStyleAccessorFn,
datumIndex,
graphicsFactory,
defaultStyle: outsideLabelStyle);
Expand All @@ -261,7 +259,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
continue;
}

final bounds = element.bounds;
final bounds = element.bounds!;

// Get space available inside and outside the bar.
final totalPadding = labelPadding * 2;
Expand Down Expand Up @@ -295,15 +293,15 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
}

// Only calculate and draw label if there's actually space for the label.
if (labelElement.maxWidth < 0 ||
if (labelElement.maxWidth! < 0 ||
(labelElement.maxWidthStrategy == null &&
labelElement.measurement.horizontalSliceWidth >
labelElement.maxWidth)) {
labelElement.maxWidth!)) {
return;
}

// Calculate the start position of label based on [labelAnchor].
int labelX;
final int labelX;
if (calculatedLabelPosition == BarLabelPosition.inside) {
final anchor = _resolveLabelAnchor(
measure, labelAnchor ?? _defaultHorizontalLabelAnchor);
Expand Down Expand Up @@ -365,7 +363,7 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {

// Helper function that converts [TextStyleSpec] to [TextStyle].
TextStyle _getTextStyle(
GraphicsFactory graphicsFactory, TextStyleSpec labelSpec) {
GraphicsFactory graphicsFactory, TextStyleSpec? labelSpec) {
return graphicsFactory.createTextPaint()
..color = labelSpec?.color ?? Color.black
..fontFamily = labelSpec?.fontFamily
Expand All @@ -374,10 +372,13 @@ class BarLabelDecorator<D> extends BarRendererDecorator<D> {
}

/// Helper function to get datum specific style
TextStyle _getDatumStyle(AccessorFn<TextStyleSpec> labelFn, int datumIndex,
GraphicsFactory graphicsFactory,
{TextStyle defaultStyle}) {
final styleSpec = (labelFn != null) ? labelFn(datumIndex) : null;
TextStyle _getDatumStyle(
AccessorFn<TextStyleSpec>? labelFn,
int? datumIndex,
GraphicsFactory graphicsFactory, {
required TextStyle defaultStyle,
}) {
final styleSpec = labelFn?.call(datumIndex);
return (styleSpec != null)
? _getTextStyle(graphicsFactory, styleSpec)
: defaultStyle;
Expand Down
Loading