mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Disallow negative padding and margins
They're just as crazy in this system as they are in the web.
This commit is contained in:
parent
4840f80242
commit
dfb89fee8c
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user