From de085268f090bd8c5a90fb472ebaddec5c95c984 Mon Sep 17 00:00:00 2001 From: Samir Jindel Date: Thu, 6 Feb 2020 17:16:40 +0100 Subject: [PATCH 1/2] Ensure fields of Rect and OffsetBase classes are optimized as non-null. --- lib/ui/geometry.dart | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/ui/geometry.dart b/lib/ui/geometry.dart index 11849d3a8c4a9..b99651ce5be0b 100644 --- a/lib/ui/geometry.dart +++ b/lib/ui/geometry.dart @@ -12,7 +12,11 @@ abstract class OffsetBase { /// /// The first argument sets the horizontal component, and the second the /// vertical component. - const OffsetBase(this._dx, this._dy); + const OffsetBase(double dx, double dy) + : _dx = dx ?? 0.0 + , _dy = dy ?? 0.0 + , assert(dx != null) + , assert(dy != null); final double _dx; final double _dy; @@ -615,11 +619,15 @@ class Size extends OffsetBase { class Rect { /// Construct a rectangle from its left, top, right, and bottom edges. @pragma('vm:entry-point') - const Rect.fromLTRB(this.left, this.top, this.right, this.bottom) - : assert(left != null), - assert(top != null), - assert(right != null), - assert(bottom != null); + const Rect.fromLTRB(double left, double top, double right, double bottom) + : left = left ?? 0.0, + right = right ?? 0.0, + top = top ?? 0.0, + bottom = bottom ?? 0.0, + assert(left != null), + assert(top != null), + assert(right != null), + assert(bottom != null); /// Construct a rectangle from its left and top edges, its width, and its /// height. From 2aaff8fc3bb51cf7eed35c351aaabef83b8e93e4 Mon Sep 17 00:00:00 2001 From: Samir Jindel Date: Fri, 7 Feb 2020 12:45:22 +0100 Subject: [PATCH 2/2] Update web_ui and formatting --- lib/ui/geometry.dart | 24 ++++++++++++------------ lib/web_ui/lib/src/ui/geometry.dart | 3 ++- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/ui/geometry.dart b/lib/ui/geometry.dart index b99651ce5be0b..aab15f960add8 100644 --- a/lib/ui/geometry.dart +++ b/lib/ui/geometry.dart @@ -13,10 +13,10 @@ abstract class OffsetBase { /// The first argument sets the horizontal component, and the second the /// vertical component. const OffsetBase(double dx, double dy) - : _dx = dx ?? 0.0 - , _dy = dy ?? 0.0 - , assert(dx != null) - , assert(dy != null); + : _dx = dx ?? 0.0, + _dy = dy ?? 0.0, + assert(dx != null), + assert(dy != null); final double _dx; final double _dy; @@ -620,14 +620,14 @@ class Rect { /// Construct a rectangle from its left, top, right, and bottom edges. @pragma('vm:entry-point') const Rect.fromLTRB(double left, double top, double right, double bottom) - : left = left ?? 0.0, - right = right ?? 0.0, - top = top ?? 0.0, - bottom = bottom ?? 0.0, - assert(left != null), - assert(top != null), - assert(right != null), - assert(bottom != null); + : left = left ?? 0.0, + right = right ?? 0.0, + top = top ?? 0.0, + bottom = bottom ?? 0.0, + assert(left != null), + assert(top != null), + assert(right != null), + assert(bottom != null); /// Construct a rectangle from its left and top edges, its width, and its /// height. diff --git a/lib/web_ui/lib/src/ui/geometry.dart b/lib/web_ui/lib/src/ui/geometry.dart index dc50d198fbfce..7ef42175e7e33 100644 --- a/lib/web_ui/lib/src/ui/geometry.dart +++ b/lib/web_ui/lib/src/ui/geometry.dart @@ -12,7 +12,8 @@ abstract class OffsetBase { /// /// The first argument sets the horizontal component, and the second the /// vertical component. - const OffsetBase(this._dx, this._dy); + const OffsetBase(double dx, double dy) + : _dx = dx, _dy = dy; final double _dx; final double _dy;