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 {
/// The offset from the left
final double left;
bool get isNonNegative => top >= 0.0 && right >= 0.0 && bottom >= 0.0 && left >= 0.0;
bool operator ==(other) {
if (identical(this, other))
return true;
......
......@@ -79,6 +79,7 @@ class RenderPadding extends RenderShiftedBox {
EdgeDims get padding => _padding;
void set padding (EdgeDims value) {
assert(value != null);
assert(value.isNonNegative);
if (_padding == value)
return;
_padding = value;
......
......@@ -393,7 +393,10 @@ class Container extends Component {
this.margin,
this.padding,
this.transform
}) : super(key: key);
}) : super(key: key) {
assert(margin == null || margin.isNonNegative);
assert(padding == null || padding.isNonNegative);
}
final Widget child;
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