Add asserts requiring BoxConstraints' parameters to be non-null (#48295)

This commit is contained in:
Tianguang 2020-01-13 21:34:30 +01:00 committed by GitHub
parent 5df63738f8
commit d7d642653a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -90,7 +90,10 @@ class BoxConstraints extends Constraints {
this.maxWidth = double.infinity,
this.minHeight = 0.0,
this.maxHeight = double.infinity,
});
}) : assert (minWidth != null),
assert (maxWidth != null),
assert (minHeight != null),
assert (maxHeight != null);
/// Creates box constraints that is respected only by the given size.
BoxConstraints.tight(Size size)

View File

@ -1007,6 +1007,13 @@ void main() {
expect(innerConstrained.localToGlobal(Offset.zero, ancestor: outerConstrained).dy, 25.0);
});
});
test('BoxConstraints parameters should be non-null', () {
expect(() => BoxConstraints(minWidth: null), throwsAssertionError);
expect(() => BoxConstraints(maxWidth: null), throwsAssertionError);
expect(() => BoxConstraints(minHeight: null), throwsAssertionError);
expect(() => BoxConstraints(maxHeight: null), throwsAssertionError);
});
}
class _DummyHitTestTarget implements HitTestTarget {