From e8a638ecf9e55149b5880b252e4a7824631481ad Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Thu, 7 Jul 2016 07:49:35 -0700 Subject: [PATCH] Minor RenderBox improvements (#4837) * Make the size setter on RenderBox protected to avoid setting from outside the class. * Make normalize on BoxConstraints always return an object that isNormalized. --- packages/flutter/lib/src/rendering/box.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index cc775a5310..c39edfccfb 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -392,6 +392,10 @@ class BoxConstraints extends Constraints { /// The returned [maxWidth] is at least as large as the [minWidth]. Similarly, /// the returned [maxHeight] is at least as large as the [minHeight]. BoxConstraints normalize() { + if (isNormalized) + return this; + final double minWidth = this.minWidth >= 0.0 ? this.minWidth : 0.0; + final double minHeight = this.minHeight >= 0.0 ? this.minHeight : 0.0; return new BoxConstraints( minWidth: minWidth, maxWidth: minWidth > maxWidth ? minWidth : maxWidth, @@ -829,6 +833,7 @@ abstract class RenderBox extends RenderObject { return _size; } Size _size; + @protected set size(Size value) { assert(!(debugDoingThisResize && debugDoingThisLayout)); assert(sizedByParent || !debugDoingThisResize);