Commit 4d84e1b7 authored by Adam Barth's avatar Adam Barth

Disallow negative padding and margins

They're just as crazy in this system as they are in the web.
parent 4e01c054
...@@ -45,6 +45,8 @@ class EdgeDims { ...@@ -45,6 +45,8 @@ class EdgeDims {
/// The offset from the left /// The offset from the left
final double left; final double left;
bool get isNonNegative => top >= 0.0 && right >= 0.0 && bottom >= 0.0 && left >= 0.0;
bool operator ==(other) { bool operator ==(other) {
if (identical(this, other)) if (identical(this, other))
return true; return true;
......
...@@ -79,6 +79,7 @@ class RenderPadding extends RenderShiftedBox { ...@@ -79,6 +79,7 @@ class RenderPadding extends RenderShiftedBox {
EdgeDims get padding => _padding; EdgeDims get padding => _padding;
void set padding (EdgeDims value) { void set padding (EdgeDims value) {
assert(value != null); assert(value != null);
assert(value.isNonNegative);
if (_padding == value) if (_padding == value)
return; return;
_padding = value; _padding = value;
......
...@@ -393,7 +393,10 @@ class Container extends Component { ...@@ -393,7 +393,10 @@ class Container extends Component {
this.margin, this.margin,
this.padding, this.padding,
this.transform this.transform
}) : super(key: key); }) : super(key: key) {
assert(margin == null || margin.isNonNegative);
assert(padding == null || padding.isNonNegative);
}
final Widget child; final Widget child;
final BoxConstraints constraints; final BoxConstraints constraints;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment