diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 6ebc8769b6..7939ba6243 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -2308,9 +2308,7 @@ class Expanded extends Flexible { Key key, int flex: 1, @required Widget child, - }) : super(key: key, flex: flex, fit: FlexFit.tight, child: child) { - assert(flex > 0); - } + }) : super(key: key, flex: flex, fit: FlexFit.tight, child: child); } /// A widget that implements the flow layout algorithm. diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index 388d192ad1..02d5444f4d 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -7,12 +7,13 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; 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; await tester.pumpWidget( new Container( decoration: const BoxDecoration( - backgroundColor: const Color(0xFF00FF00) + backgroundColor: const Color(0xFF00FF00), ), child: new Stack( children: [ @@ -27,24 +28,34 @@ void main() { }, child: new Container( decoration: const BoxDecoration( - backgroundColor: const Color(0xFF0000FF) - ), + backgroundColor: const Color(0xFF0000FF)), width: 100.0, height: 100.0, child: new Center( - child: new Text('X') - ) - ) - ) - ] - ) - ) - ] - ) - ) + child: new Text('X'), + ), + ), + ), + ], + ), + ), + ], + ), + ), ); await tester.tap(find.text('X')); expect(didReceiveTap, isTrue); }); + + testWidgets('Can pass null for flex', (WidgetTester tester) async { + await tester.pumpWidget( + new Row( + children: [ + new Expanded(flex: null, child: new Text('one')), + new Flexible(flex: null, child: new Text('two')), + ], + ), + ); + }); }