Unverified Commit 037df5f2 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Remove unneeded assert in UnconstrainedBox (#16778)

This addresses #16593 by removing the unneeded assert in the setter for constrainedAxis. Null was meant to be allowed there.

This replaces #16599 and fixes #16593, reported by @maksimr
parent b5af0a91
...@@ -626,7 +626,6 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow ...@@ -626,7 +626,6 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow
Axis get constrainedAxis => _constrainedAxis; Axis get constrainedAxis => _constrainedAxis;
Axis _constrainedAxis; Axis _constrainedAxis;
set constrainedAxis(Axis value) { set constrainedAxis(Axis value) {
assert(value != null);
if (_constrainedAxis == value) if (_constrainedAxis == value)
return; return;
_constrainedAxis = value; _constrainedAxis = value;
......
...@@ -135,6 +135,7 @@ void main() { ...@@ -135,6 +135,7 @@ void main() {
test('UnconstrainedBox expands to fit children', () { test('UnconstrainedBox expands to fit children', () {
final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox(
constrainedAxis: Axis.horizontal, // This is reset to null below.
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: new RenderConstrainedBox( child: new RenderConstrainedBox(
additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0), additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0),
...@@ -150,6 +151,9 @@ void main() { ...@@ -150,6 +151,9 @@ void main() {
maxHeight: 200.0, maxHeight: 200.0,
), ),
); );
// Check that we can update the constrained axis to null.
unconstrained.constrainedAxis = null;
renderer.reassembleApplication();
expect(unconstrained.size.width, equals(200.0), reason: 'unconstrained width'); expect(unconstrained.size.width, equals(200.0), reason: 'unconstrained width');
expect(unconstrained.size.height, equals(200.0), reason: 'unconstrained height'); expect(unconstrained.size.height, equals(200.0), reason: 'unconstrained height');
...@@ -207,7 +211,7 @@ void main() { ...@@ -207,7 +211,7 @@ void main() {
); );
}); });
test('honors constrainedAxis=Axis.horizontal', () { test('UnconstrainedBox honors constrainedAxis=Axis.horizontal', () {
final RenderConstrainedBox flexible = final RenderConstrainedBox flexible =
new RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(height: 200.0)); new RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(height: 200.0));
final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox(
...@@ -231,7 +235,7 @@ void main() { ...@@ -231,7 +235,7 @@ void main() {
expect(unconstrained.size.height, equals(200.0), reason: 'unconstrained height'); expect(unconstrained.size.height, equals(200.0), reason: 'unconstrained height');
}); });
test('honors constrainedAxis=Axis.vertical', () { test('UnconstrainedBox honors constrainedAxis=Axis.vertical', () {
final RenderConstrainedBox flexible = final RenderConstrainedBox flexible =
new RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(width: 200.0)); new RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(width: 200.0));
final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox(
......
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