From bf74bac537b137fe458cdc8355543263ff4abaf6 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 2 Nov 2015 16:38:37 -0800 Subject: [PATCH] Make RRect immutable and replace RRect.setRectXY with a fromRectXY constructor --- packages/flutter/lib/src/material/checkbox.dart | 4 ++-- packages/flutter/lib/src/material/switch.dart | 4 ++-- packages/flutter/lib/src/painting/box_painter.dart | 6 +++--- packages/flutter/lib/src/rendering/proxy_box.dart | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index 21012be193a..9e576e7c7a6 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -151,8 +151,8 @@ class _RenderCheckbox extends RenderToggleable { // Create an inner rectangle to cover inside of rectangle. This is needed to avoid // painting artefacts caused by overlayed paintings. Rect innerRect = rect.deflate(1.0); - ui.RRect rrect = new ui.RRect() - ..setRectXY(rect, _kEdgeRadius, _kEdgeRadius); + ui.RRect rrect = new ui.RRect.fromRectXY( + rect, _kEdgeRadius, _kEdgeRadius); // Outline of the empty rrect paint.style = ui.PaintingStyle.stroke; diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index d5872475e48..9d7215b60c3 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -124,8 +124,8 @@ class _RenderSwitch extends RenderToggleable { Rect rect = new Rect.fromLTWH(offset.dx, offset.dy + _kSwitchHeight / 2.0 - _kTrackHeight / 2.0, _kTrackWidth, _kTrackHeight); - ui.RRect rrect = new ui.RRect() - ..setRectXY(rect, _kTrackRadius, _kTrackRadius); + ui.RRect rrect = new ui.RRect.fromRectXY( + rect, _kTrackRadius, _kTrackRadius); canvas.drawRRect(rrect, paint); if (_radialReaction != null) diff --git a/packages/flutter/lib/src/painting/box_painter.dart b/packages/flutter/lib/src/painting/box_painter.dart index e17f02f3ed3..c27e41015bf 100644 --- a/packages/flutter/lib/src/painting/box_painter.dart +++ b/packages/flutter/lib/src/painting/box_painter.dart @@ -949,7 +949,7 @@ class BoxPainter { canvas.drawRect(rect, _backgroundPaint); } else { double radius = _getEffectiveBorderRadius(rect); - canvas.drawRRect(new ui.RRect()..setRectXY(rect, radius, radius), _backgroundPaint); + canvas.drawRRect(new ui.RRect.fromRectXY(rect, radius, radius), _backgroundPaint); } break; } @@ -1043,8 +1043,8 @@ class BoxPainter { double width = _decoration.border.top.width; double radius = _getEffectiveBorderRadius(rect); - ui.RRect outer = new ui.RRect()..setRectXY(rect, radius, radius); - ui.RRect inner = new ui.RRect()..setRectXY(rect.deflate(width), radius - width, radius - width); + ui.RRect outer = new ui.RRect.fromRectXY(rect, radius, radius); + ui.RRect inner = new ui.RRect.fromRectXY(rect.deflate(width), radius - width, radius - width); canvas.drawDRRect(outer, inner, new Paint()..color = color); } diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 1b50c2b4a90..8ba38c29859 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -587,7 +587,7 @@ class RenderClipRRect extends RenderProxyBox { void paint(PaintingContext context, Offset offset) { if (child != null) { Rect rect = offset & size; - ui.RRect rrect = new ui.RRect()..setRectXY(rect, xRadius, yRadius); + ui.RRect rrect = new ui.RRect.fromRectXY(rect, xRadius, yRadius); context.paintChildWithClipRRect(child, offset.toPoint(), rect, rrect); } }