Commit b40f0cae authored by Adam Barth's avatar Adam Barth Committed by GitHub

Allow Expanded.flex to be null (#7384)

Some clients pass null, which was previously allowed by Flexible.

Fixes #7383
parent fd3e0b7e
...@@ -2308,9 +2308,7 @@ class Expanded extends Flexible { ...@@ -2308,9 +2308,7 @@ class Expanded extends Flexible {
Key key, Key key,
int flex: 1, int flex: 1,
@required Widget child, @required Widget child,
}) : super(key: key, flex: flex, fit: FlexFit.tight, child: child) { }) : super(key: key, flex: flex, fit: FlexFit.tight, child: child);
assert(flex > 0);
}
} }
/// A widget that implements the flow layout algorithm. /// A widget that implements the flow layout algorithm.
......
...@@ -7,12 +7,13 @@ import 'package:flutter/rendering.dart'; ...@@ -7,12 +7,13 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
void main() { void main() {
testWidgets('Can hit test flex children of stacks', (WidgetTester tester) async { testWidgets('Can hit test flex children of stacks',
(WidgetTester tester) async {
bool didReceiveTap = false; bool didReceiveTap = false;
await tester.pumpWidget( await tester.pumpWidget(
new Container( new Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
backgroundColor: const Color(0xFF00FF00) backgroundColor: const Color(0xFF00FF00),
), ),
child: new Stack( child: new Stack(
children: <Widget>[ children: <Widget>[
...@@ -27,24 +28,34 @@ void main() { ...@@ -27,24 +28,34 @@ void main() {
}, },
child: new Container( child: new Container(
decoration: const BoxDecoration( decoration: const BoxDecoration(
backgroundColor: const Color(0xFF0000FF) backgroundColor: const Color(0xFF0000FF)),
),
width: 100.0, width: 100.0,
height: 100.0, height: 100.0,
child: new Center( child: new Center(
child: new Text('X') child: new Text('X'),
) ),
) ),
) ),
] ],
) ),
) ),
] ],
) ),
) ),
); );
await tester.tap(find.text('X')); await tester.tap(find.text('X'));
expect(didReceiveTap, isTrue); expect(didReceiveTap, isTrue);
}); });
testWidgets('Can pass null for flex', (WidgetTester tester) async {
await tester.pumpWidget(
new Row(
children: <Widget>[
new Expanded(flex: null, child: new Text('one')),
new Flexible(flex: null, child: new Text('two')),
],
),
);
});
} }
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