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.
This commit is contained in:
Adam Barth 2016-07-07 07:49:35 -07:00 committed by GitHub
parent 04dca44f27
commit e8a638ecf9

View file

@ -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);