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

Commit 547227e

Browse files
stereotype441stuartmorgan-g
authored andcommitted
Update code in preparation for the fix to dart-lang/language#1785 to roll out.
In short, this bug prevents implicitly typed condition variables from participating in type promotion in some circumstances (see the bug for more details). Since the bug only occurs when the condition variable is implicitly typed, we can ensure a smooth rollout by giving explicit `bool` types to the condition variables affected by this bug. Once the fix has fully rolled out to google3 we will be able to remove these explicit types once again. Tested: TAP --sample ran all affected tests and none failed http://test/OCL:394261565:BASE:394223559:1630517438374:b19cc4e4 PiperOrigin-RevId: 394291389
1 parent 76b01cb commit 547227e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

charts_flutter/lib/src/chart_canvas.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,16 @@ class ChartCanvas implements common.ChartCanvas {
150150
common.Color? stroke,
151151
double? strokeWidthPx,
152152
Rectangle<num>? drawAreaBounds}) {
153-
final drawStroke =
153+
// TODO: remove this explicit `bool` type when no longer needed
154+
// to work around https://github.com/dart-lang/language/issues/1785
155+
final bool drawStroke =
154156
(strokeWidthPx != null && strokeWidthPx > 0.0 && stroke != null);
155157

156158
final strokeWidthOffset = (drawStroke ? strokeWidthPx : 0);
157159

158160
// Factor out stroke width, if a stroke is enabled.
159161
final fillRectBounds = new Rectangle<num>(
160-
bounds.left + strokeWidthOffset! / 2,
162+
bounds.left + strokeWidthOffset / 2,
161163
bounds.top + strokeWidthOffset / 2,
162164
bounds.width - strokeWidthOffset,
163165
bounds.height - strokeWidthOffset);
@@ -188,16 +190,15 @@ class ChartCanvas implements common.ChartCanvas {
188190
// [Canvas.drawRect] does not support drawing a rectangle with both a fill
189191
// and a stroke at this time. Use a separate rect for the stroke.
190192
if (drawStroke) {
191-
_paint.color =
192-
new Color.fromARGB(stroke!.a, stroke.r, stroke.g, stroke.b);
193+
_paint.color = new Color.fromARGB(stroke.a, stroke.r, stroke.g, stroke.b);
193194
// Set shader to null if no draw area bounds so it can use the color
194195
// instead.
195196
_paint.shader = drawAreaBounds != null
196197
? _createHintGradient(drawAreaBounds.left.toDouble(),
197198
drawAreaBounds.top.toDouble(), stroke)
198199
: null;
199200
_paint.strokeJoin = StrokeJoin.round;
200-
_paint.strokeWidth = strokeWidthPx!;
201+
_paint.strokeWidth = strokeWidthPx;
201202
_paint.style = PaintingStyle.stroke;
202203

203204
canvas.drawRect(_getRect(bounds), _paint);

0 commit comments

Comments
 (0)