diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index 7f3ae3d83bc..03541ff9da9 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -91,7 +91,7 @@ class ComplexLayoutState extends State { ), body: new Column( children: [ - new Flexible( + new Expanded( child: new LazyBlock( key: new Key('main-scroll'), delegate: new FancyItemDelegate() @@ -339,7 +339,7 @@ class UserHeader extends StatelessWidget { height: 32.0 ) ), - new Flexible( + new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -474,7 +474,7 @@ class ItemGalleryBox extends StatelessWidget { values: tabNames, child: new Column( children: [ - new Flexible( + new Expanded( child: new TabBarView( children: tabNames.map((String tabName) { return new Container( @@ -484,7 +484,7 @@ class ItemGalleryBox extends StatelessWidget { child: new Card( child: new Column( children: [ - new Flexible( + new Expanded( child: new Container( decoration: new BoxDecoration( backgroundColor: Theme.of(context).primaryColor @@ -504,7 +504,7 @@ class ItemGalleryBox extends StatelessWidget { icon: new Icon(Icons.event), onPressed: () { print('Pressed event'); } ), - new Flexible( + new Expanded( child: new Padding( padding: new EdgeInsets.only(left: 8.0), child: new Text('This is item $tabName') @@ -598,7 +598,7 @@ class GalleryDrawer extends StatelessWidget { selected: ComplexLayoutApp.of(context).lightTheme, child: new Row( children: [ - new Flexible(child: new Text('Light')), + new Expanded(child: new Text('Light')), new Radio( value: true, groupValue: ComplexLayoutApp.of(context).lightTheme, @@ -613,7 +613,7 @@ class GalleryDrawer extends StatelessWidget { selected: !ComplexLayoutApp.of(context).lightTheme, child: new Row( children: [ - new Flexible(child: new Text('Dark')), + new Expanded(child: new Text('Dark')), new Radio( value: false, groupValue: ComplexLayoutApp.of(context).lightTheme, @@ -629,7 +629,7 @@ class GalleryDrawer extends StatelessWidget { onPressed: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); }, child: new Row( children: [ - new Flexible(child: new Text('Animate Slowly')), + new Expanded(child: new Text('Animate Slowly')), new Checkbox( value: timeDilation != 1.0, onChanged: (bool value) { ComplexLayoutApp.of(context).toggleAnimationSpeed(); } diff --git a/dev/manual_tests/card_collection.dart b/dev/manual_tests/card_collection.dart index 40aef97f797..f20c0d8cda2 100644 --- a/dev/manual_tests/card_collection.dart +++ b/dev/manual_tests/card_collection.dart @@ -213,7 +213,7 @@ class CardCollectionState extends State { onPressed: enabled ? callback : null, child: new Row( children: [ - new Flexible(child: new Text(label)), + new Expanded(child: new Text(label)), new Checkbox( value: value, onChanged: enabled ? (_) { callback(); } : null @@ -229,7 +229,7 @@ class CardCollectionState extends State { onPressed: enabled ? () { onChanged(itemValue); } : null, child: new Row( children: [ - new Flexible(child: new Text(label)), + new Expanded(child: new Text(label)), new Radio>( value: itemValue, groupValue: currentValue, @@ -246,7 +246,7 @@ class CardCollectionState extends State { onPressed: enabled ? () { onChanged(itemValue); } : null, child: new Row( children: [ - new Flexible(child: new Text(label)), + new Expanded(child: new Text(label)), new Radio( value: itemValue, groupValue: currentValue, @@ -263,7 +263,7 @@ class CardCollectionState extends State { onPressed: enabled ? () { onChanged(itemValue); } : null, child: new Row( children: [ - new Flexible(child: new Text(label)), + new Expanded(child: new Text(label)), new Radio( value: itemValue, groupValue: currentValue, @@ -374,7 +374,7 @@ class CardCollectionState extends State { child: new Row( children: [ leftArrowIcon, - new Flexible( + new Expanded( child: new Text(backgroundMessage, style: backgroundTextStyle, textAlign: TextAlign.center diff --git a/dev/manual_tests/drag_and_drop.dart b/dev/manual_tests/drag_and_drop.dart index c96dc718829..7aa21d57b0a 100644 --- a/dev/manual_tests/drag_and_drop.dart +++ b/dev/manual_tests/drag_and_drop.dart @@ -242,8 +242,10 @@ class DragAndDropAppState extends State { ), body: new Column( children: [ - new Flexible( + new Expanded( child: new Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ new ExampleDragSource( color: Colors.yellow[300], @@ -264,28 +266,26 @@ class DragAndDropAppState extends State { child: new Text('above') ), ], - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceAround ) ), - new Flexible( + new Expanded( child: new Row( children: [ - new Flexible(child: new ExampleDragTarget()), - new Flexible(child: new ExampleDragTarget()), - new Flexible(child: new ExampleDragTarget()), - new Flexible(child: new ExampleDragTarget()), + new Expanded(child: new ExampleDragTarget()), + new Expanded(child: new ExampleDragTarget()), + new Expanded(child: new ExampleDragTarget()), + new Expanded(child: new ExampleDragTarget()), ] ) ), - new Flexible( + new Expanded( child: new Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ new MovableBall(1, position, moveBall), new MovableBall(2, position, moveBall), new MovableBall(3, position, moveBall), ], - mainAxisAlignment: MainAxisAlignment.spaceAround ) ), ] diff --git a/dev/manual_tests/pageable_list.dart b/dev/manual_tests/pageable_list.dart index f6fba19c6e9..2547fa17ce1 100644 --- a/dev/manual_tests/pageable_list.dart +++ b/dev/manual_tests/pageable_list.dart @@ -102,7 +102,7 @@ class PageableListAppState extends State { onPressed: toggleItemsWrap, child: new Row( children: [ - new Flexible(child: new Text('Scrolling wraps around')), + new Expanded(child: new Text('Scrolling wraps around')), // TODO(abarth): Actually make this checkbox change this value. new Checkbox(value: itemsWrap, onChanged: null) ] diff --git a/examples/flutter_gallery/lib/demo/calculator/home.dart b/examples/flutter_gallery/lib/demo/calculator/home.dart index 9b54632f3e0..f2fab10dfec 100644 --- a/examples/flutter_gallery/lib/demo/calculator/home.dart +++ b/examples/flutter_gallery/lib/demo/calculator/home.dart @@ -122,12 +122,12 @@ class _CalculatorState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ // Give the key-pad 3/5 of the vertical space and the display 2/5. - new Flexible( + new Expanded( flex: 2, child: new CalcDisplay(content: _expression.toString()) ), new Divider(height: 1.0), - new Flexible( + new Expanded( flex: 3, child: new KeyPad(calcState: this) ) @@ -170,7 +170,7 @@ class KeyPad extends StatelessWidget { child: new Material( child: new Row( children: [ - new Flexible( + new Expanded( // We set flex equal to the number of columns so that the main keypad // and the op keypad have sizes proportional to their number of // columns. @@ -200,7 +200,7 @@ class KeyPad extends StatelessWidget { ] ) ), - new Flexible( + new Expanded( child: new Material( color: themeData.backgroundColor, child: new Column( @@ -228,7 +228,7 @@ class KeyRow extends StatelessWidget { @override Widget build(BuildContext context) { - return new Flexible( + return new Expanded( child: new Row( mainAxisAlignment: MainAxisAlignment.center, children: this.keys @@ -246,7 +246,7 @@ class CalcKey extends StatelessWidget { @override Widget build(BuildContext context) { final Orientation orientation = MediaQuery.of(context).orientation; - return new Flexible( + return new Expanded( child: new InkResponse( onTap: this.onTap, child: new Center( diff --git a/examples/flutter_gallery/lib/demo/cards_demo.dart b/examples/flutter_gallery/lib/demo/cards_demo.dart index 923f33c8750..363c9e0887a 100644 --- a/examples/flutter_gallery/lib/demo/cards_demo.dart +++ b/examples/flutter_gallery/lib/demo/cards_demo.dart @@ -83,7 +83,7 @@ class TravelDestinationItem extends StatelessWidget { ) ), // description and share/expore buttons - new Flexible( + new Expanded( child: new Padding( padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0.0), child: new DefaultTextStyle( diff --git a/examples/flutter_gallery/lib/demo/contacts_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart index 0e8a849d0a0..8acb31a5a3d 100644 --- a/examples/flutter_gallery/lib/demo/contacts_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart @@ -28,7 +28,7 @@ class _ContactCategory extends StatelessWidget { width: 72.0, child: new Icon(icon, color: themeData.primaryColor) ), - new Flexible(child: new Column(children: children)) + new Expanded(child: new Column(children: children)) ] ) ) @@ -53,7 +53,7 @@ class _ContactItem extends StatelessWidget { columnChildren.add(new Text(lines.last, style: themeData.textTheme.caption)); List rowChildren = [ - new Flexible( + new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, children: columnChildren diff --git a/examples/flutter_gallery/lib/demo/date_and_time_picker_demo.dart b/examples/flutter_gallery/lib/demo/date_and_time_picker_demo.dart index 3358bcf0714..c87b73d5c52 100644 --- a/examples/flutter_gallery/lib/demo/date_and_time_picker_demo.dart +++ b/examples/flutter_gallery/lib/demo/date_and_time_picker_demo.dart @@ -86,7 +86,7 @@ class _DateTimePicker extends StatelessWidget { return new Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - new Flexible( + new Expanded( flex: 4, child: new _InputDropdown( labelText: labelText, @@ -96,7 +96,7 @@ class _DateTimePicker extends StatelessWidget { ), ), new SizedBox(width: 12.0), - new Flexible( + new Expanded( flex: 3, child: new _InputDropdown( valueText: selectedTime.toString(), diff --git a/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart b/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart index 675e1eb1560..c80536dc5d2 100644 --- a/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart +++ b/examples/flutter_gallery/lib/demo/expansion_panels_demo.dart @@ -45,14 +45,14 @@ class DualHeaderWithHint extends StatelessWidget { return new Row( children: [ - new Flexible( + new Expanded( flex: 2, child: new Container( margin: const EdgeInsets.only(left: 24.0), child: new Text(name, style: textTheme.body1.copyWith(fontSize: 15.0)) ) ), - new Flexible( + new Expanded( flex: 3, child: new Container( margin: const EdgeInsets.only(left: 24.0), diff --git a/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart b/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart index 25d58ff6991..c56d0ffcfce 100644 --- a/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart @@ -35,7 +35,7 @@ class DateTimeItem extends StatelessWidget { style: theme.textTheme.subhead, child: new Row( children: [ - new Flexible( + new Expanded( child: new Container( padding: const EdgeInsets.symmetric(vertical: 8.0), decoration: new BoxDecoration( diff --git a/examples/flutter_gallery/lib/demo/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/grid_list_demo.dart index 591757eebd5..150ffa90e34 100644 --- a/examples/flutter_gallery/lib/demo/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/grid_list_demo.dart @@ -344,7 +344,7 @@ class GridListDemoState extends State { ), body: new Column( children: [ - new Flexible( + new Expanded( child: new ScrollableGrid( scrollableKey: _scrollableKey, delegate: new FixedColumnCountGridDelegate( diff --git a/examples/flutter_gallery/lib/demo/icons_demo.dart b/examples/flutter_gallery/lib/demo/icons_demo.dart index c0a82fd09fc..19828447a79 100644 --- a/examples/flutter_gallery/lib/demo/icons_demo.dart +++ b/examples/flutter_gallery/lib/demo/icons_demo.dart @@ -83,20 +83,17 @@ class IconsDemoState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Flexible( - flex: 0, - child: new Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - new Text('Size', style: textStyle), - buildSizeLabel(18, textStyle), - buildSizeLabel(24, textStyle), - buildSizeLabel(36, textStyle), - buildSizeLabel(48, textStyle) - ] - ) + new Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + new Text('Size', style: textStyle), + buildSizeLabel(18, textStyle), + buildSizeLabel(24, textStyle), + buildSizeLabel(36, textStyle), + buildSizeLabel(48, textStyle) + ] ), - new Flexible( + new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -108,7 +105,7 @@ class IconsDemoState extends State { ] ) ), - new Flexible( + new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -122,7 +119,7 @@ class IconsDemoState extends State { ) ] ), - new Flexible( + new Expanded( child: new Center( child: new IconTheme( data: new IconThemeData(opacity: 1.0), diff --git a/examples/flutter_gallery/lib/demo/page_selector_demo.dart b/examples/flutter_gallery/lib/demo/page_selector_demo.dart index e9afe8bd761..deda72ecc38 100644 --- a/examples/flutter_gallery/lib/demo/page_selector_demo.dart +++ b/examples/flutter_gallery/lib/demo/page_selector_demo.dart @@ -55,7 +55,7 @@ class PageSelectorDemo extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween ) ), - new Flexible( + new Expanded( child: new TabBarView( children: icons.map((IconData icon) { return new Container( diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index f42dfc2f9dc..9f16edfdf0b 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -253,7 +253,7 @@ class RecipeCard extends StatelessWidget { tag: recipe.imagePath, child: new Image.asset(recipe.imagePath, fit: ImageFit.contain) ), - new Flexible( + new Expanded( child: new Row( children: [ new Padding( @@ -264,7 +264,7 @@ class RecipeCard extends StatelessWidget { height: 48.0 ) ), - new Flexible( + new Expanded( child: new Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index 6b77e689e46..673ebd8f163 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -81,7 +81,7 @@ class VendorItem extends StatelessWidget { ) ), new SizedBox(width: 8.0), - new Flexible( + new Expanded( child: new Text(vendor.name, style: ShrineTheme.of(context).vendorItemStyle) ) ] @@ -192,7 +192,7 @@ class FeatureItem extends StatelessWidget { child: new FeaturePriceItem(product: product) ) ), - new Flexible( + new Expanded( child: new CustomMultiChildLayout( delegate: new FeatureLayout(), children: [ diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index 37c125e4322..94cc6081afb 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -56,7 +56,7 @@ class OrderItem extends StatelessWidget { ) ) ), - new Flexible( + new Expanded( child: new Text(product.name, style: theme.featureTitleStyle) ) ] diff --git a/examples/flutter_gallery/lib/demo/text_field_demo.dart b/examples/flutter_gallery/lib/demo/text_field_demo.dart index 9a3d87df3d3..8fa86547880 100644 --- a/examples/flutter_gallery/lib/demo/text_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/text_field_demo.dart @@ -110,7 +110,7 @@ class TextFieldDemoState extends State { new Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Flexible( + new Expanded( child: new InputFormField( key: _passwordFieldKey, hintText: 'How do you log in?', @@ -120,7 +120,7 @@ class TextFieldDemoState extends State { ) ), new SizedBox(width: 16.0), - new Flexible( + new Expanded( child: new InputFormField( hintText: 'How do you log in?', labelText: 'Re-type Password', diff --git a/examples/flutter_gallery/lib/demo/typography_demo.dart b/examples/flutter_gallery/lib/demo/typography_demo.dart index 2422524bba5..29652859696 100644 --- a/examples/flutter_gallery/lib/demo/typography_demo.dart +++ b/examples/flutter_gallery/lib/demo/typography_demo.dart @@ -29,7 +29,7 @@ class TextStyleItem extends StatelessWidget { width: 72.0, child: new Text(name, style: nameStyle) ), - new Flexible( + new Expanded( child: new Text(text, style: style.copyWith(height: 1.0)) ) ] diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index 3dc7d9cc569..59634be8a70 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart @@ -91,7 +91,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { style: Theme.of(context).textTheme.subhead ) ), - new Flexible(child: demo.widget) + new Expanded(child: demo.widget) ] ); }).toList() diff --git a/examples/flutter_gallery/lib/gallery/drawer.dart b/examples/flutter_gallery/lib/gallery/drawer.dart index 97005744c5c..b2490dbdab8 100644 --- a/examples/flutter_gallery/lib/gallery/drawer.dart +++ b/examples/flutter_gallery/lib/gallery/drawer.dart @@ -128,7 +128,7 @@ class GalleryDrawer extends StatelessWidget { selected: useLightTheme, child: new Row( children: [ - new Flexible(child: new Text('Light')), + new Expanded(child: new Text('Light')), new Radio( value: true, groupValue: useLightTheme, @@ -144,7 +144,7 @@ class GalleryDrawer extends StatelessWidget { selected: useLightTheme, child: new Row( children: [ - new Flexible(child: new Text('Dark')), + new Expanded(child: new Text('Dark')), new Radio( value: false, groupValue: useLightTheme, @@ -161,7 +161,7 @@ class GalleryDrawer extends StatelessWidget { selected: Theme.of(context).platform == TargetPlatform.android, child: new Row( children: [ - new Flexible(child: new Text('Android')), + new Expanded(child: new Text('Android')), new Radio( value: TargetPlatform.android, groupValue: Theme.of(context).platform, @@ -178,7 +178,7 @@ class GalleryDrawer extends StatelessWidget { selected: Theme.of(context).platform == TargetPlatform.iOS, child: new Row( children: [ - new Flexible(child: new Text('iOS')), + new Expanded(child: new Text('iOS')), new Radio( value: TargetPlatform.iOS, groupValue: Theme.of(context).platform, @@ -194,7 +194,7 @@ class GalleryDrawer extends StatelessWidget { onPressed: () { onTimeDilationChanged(timeDilation != 1.0 ? 1.0 : 20.0); }, child: new Row( children: [ - new Flexible(child: new Text('Animate Slowly')), + new Expanded(child: new Text('Animate Slowly')), new Checkbox( value: timeDilation != 1.0, onChanged: (bool value) { onTimeDilationChanged(value ? 20.0 : 1.0); } @@ -275,7 +275,7 @@ class GalleryDrawer extends StatelessWidget { selected: showPerformanceOverlay, child: new Row( children: [ - new Flexible(child: new Text('Performance Overlay')), + new Expanded(child: new Text('Performance Overlay')), new Checkbox( value: showPerformanceOverlay, onChanged: (bool value) { onShowPerformanceOverlayChanged(!showPerformanceOverlay); } @@ -292,7 +292,7 @@ class GalleryDrawer extends StatelessWidget { selected: checkerboardRasterCacheImages, child: new Row( children: [ - new Flexible(child: new Text('Checkerboard Raster Cache Images')), + new Expanded(child: new Text('Checkerboard Raster Cache Images')), new Checkbox( value: checkerboardRasterCacheImages, onChanged: (bool value) { onCheckerboardRasterCacheImagesChanged(!checkerboardRasterCacheImages); } diff --git a/examples/flutter_gallery/test/calculator/smoke_test.dart b/examples/flutter_gallery/test/calculator/smoke_test.dart index 65a6d12710d..c149e51ab4f 100644 --- a/examples/flutter_gallery/test/calculator/smoke_test.dart +++ b/examples/flutter_gallery/test/calculator/smoke_test.dart @@ -28,7 +28,7 @@ void main() { await tester.pump(); await tester.pump(const Duration(seconds: 1)); // Wait until it has finished. - Finder display = find.widgetWithText(Flexible, '12'); + Finder display = find.widgetWithText(Expanded, '12'); expect(display, findsOneWidget); }); } diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index e7026b37851..07c988aad31 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart @@ -37,7 +37,7 @@ class AdaptedGridItem extends StatelessWidget { return new Card( child: new Column( children: [ - new Flexible( + new Expanded( child: new Container( decoration: new BoxDecoration( backgroundColor: Colors.lightBlueAccent[100] @@ -48,7 +48,7 @@ class AdaptedGridItem extends StatelessWidget { margin: const EdgeInsets.only(left: 8.0), child: new Row( children: [ - new Flexible( + new Expanded( child: new Text(name) ), new IconButton( diff --git a/examples/layers/widgets/sectors.dart b/examples/layers/widgets/sectors.dart index cd6bcc11606..f211758b208 100644 --- a/examples/layers/widgets/sectors.dart +++ b/examples/layers/widgets/sectors.dart @@ -130,7 +130,7 @@ class SectorAppState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround ) ), - new Flexible( + new Expanded( child: new Container( margin: new EdgeInsets.all(8.0), decoration: new BoxDecoration( diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index bf26fe5042d..b8e50fb120e 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart @@ -23,7 +23,7 @@ class Rectangle extends StatelessWidget { @override Widget build(BuildContext context) { - return new Flexible( + return new Expanded( child: new Container( decoration: new BoxDecoration(backgroundColor: color) ) diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 5f65f3851f0..a5722cb1f67 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -153,7 +153,7 @@ class StockHomeState extends State { onPressed: () => _handleStockModeChange(StockMode.optimistic), child: new Row( children: [ - new Flexible(child: new Text('Optimistic')), + new Expanded(child: new Text('Optimistic')), new Radio(value: StockMode.optimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange) ] ) @@ -163,7 +163,7 @@ class StockHomeState extends State { onPressed: () => _handleStockModeChange(StockMode.pessimistic), child: new Row( children: [ - new Flexible(child: new Text('Pessimistic')), + new Expanded(child: new Text('Pessimistic')), new Radio(value: StockMode.pessimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange) ] ) diff --git a/examples/stocks/lib/stock_row.dart b/examples/stocks/lib/stock_row.dart index c742788b60f..53a52ab8040 100644 --- a/examples/stocks/lib/stock_row.dart +++ b/examples/stocks/lib/stock_row.dart @@ -54,22 +54,22 @@ class StockRow extends StatelessWidget { child: new StockArrow(percentChange: stock.percentChange) ) ), - new Flexible( + new Expanded( child: new Row( children: [ - new Flexible( + new Expanded( flex: 2, child: new Text( stock.symbol ) ), - new Flexible( + new Expanded( child: new Text( lastSale, textAlign: TextAlign.right ) ), - new Flexible( + new Expanded( child: new Text( changeInPrice, textAlign: TextAlign.right diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 2c05c6104ca..47bc0e6f36d 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -108,7 +108,7 @@ class StockSettingsState extends State { onPressed: () => _confirmOptimismChange(), child: new Row( children: [ - new Flexible(child: new Text('Everything is awesome')), + new Expanded(child: new Text('Everything is awesome')), new Checkbox( value: config.configuration.stockMode == StockMode.optimistic, onChanged: (bool value) => _confirmOptimismChange() @@ -121,7 +121,7 @@ class StockSettingsState extends State { onPressed: () { _handleBackupChanged(!(config.configuration.backupMode == BackupMode.enabled)); }, child: new Row( children: [ - new Flexible(child: new Text('Back up stock list to the cloud')), + new Expanded(child: new Text('Back up stock list to the cloud')), new Switch( value: config.configuration.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged @@ -134,7 +134,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowPerformanceOverlayChanged(!config.configuration.showPerformanceOverlay); }, child: new Row( children: [ - new Flexible(child: new Text('Show rendering performance overlay')), + new Expanded(child: new Text('Show rendering performance overlay')), new Switch( value: config.configuration.showPerformanceOverlay, onChanged: _handleShowPerformanceOverlayChanged @@ -147,7 +147,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowSemanticsDebuggerChanged(!config.configuration.showSemanticsDebugger); }, child: new Row( children: [ - new Flexible(child: new Text('Show semantics overlay')), + new Expanded(child: new Text('Show semantics overlay')), new Switch( value: config.configuration.showSemanticsDebugger, onChanged: _handleShowSemanticsDebuggerChanged @@ -164,7 +164,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowGridChanged(!config.configuration.debugShowGrid); }, child: new Row( children: [ - new Flexible(child: new Text('Show material grid (for debugging)')), + new Expanded(child: new Text('Show material grid (for debugging)')), new Switch( value: config.configuration.debugShowGrid, onChanged: _handleShowGridChanged @@ -177,7 +177,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowSizesChanged(!config.configuration.debugShowSizes); }, child: new Row( children: [ - new Flexible(child: new Text('Show construction lines (for debugging)')), + new Expanded(child: new Text('Show construction lines (for debugging)')), new Switch( value: config.configuration.debugShowSizes, onChanged: _handleShowSizesChanged @@ -190,7 +190,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowBaselinesChanged(!config.configuration.debugShowBaselines); }, child: new Row( children: [ - new Flexible(child: new Text('Show baselines (for debugging)')), + new Expanded(child: new Text('Show baselines (for debugging)')), new Switch( value: config.configuration.debugShowBaselines, onChanged: _handleShowBaselinesChanged @@ -203,7 +203,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowLayersChanged(!config.configuration.debugShowLayers); }, child: new Row( children: [ - new Flexible(child: new Text('Show layer boundaries (for debugging)')), + new Expanded(child: new Text('Show layer boundaries (for debugging)')), new Switch( value: config.configuration.debugShowLayers, onChanged: _handleShowLayersChanged @@ -216,7 +216,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowPointersChanged(!config.configuration.debugShowPointers); }, child: new Row( children: [ - new Flexible(child: new Text('Show pointer hit-testing (for debugging)')), + new Expanded(child: new Text('Show pointer hit-testing (for debugging)')), new Switch( value: config.configuration.debugShowPointers, onChanged: _handleShowPointersChanged @@ -229,7 +229,7 @@ class StockSettingsState extends State { onPressed: () { _handleShowRainbowChanged(!config.configuration.debugShowRainbow); }, child: new Row( children: [ - new Flexible(child: new Text('Show repaint rainbow (for debugging)')), + new Expanded(child: new Text('Show repaint rainbow (for debugging)')), new Switch( value: config.configuration.debugShowRainbow, onChanged: _handleShowRainbowChanged diff --git a/packages/flutter/bin/loader/loader_app.dart b/packages/flutter/bin/loader/loader_app.dart index fd1a8954809..5c0ce497cb1 100644 --- a/packages/flutter/bin/loader/loader_app.dart +++ b/packages/flutter/bin/loader/loader_app.dart @@ -21,12 +21,12 @@ void main() { setState = setStateRef; return new Column( children: [ - new Flexible( + new Expanded( child: new Center( child: new FlutterLogo(size: 100.0), ), ), - new Flexible( + new Expanded( child: new Builder( builder: (BuildContext context) { List children = []; @@ -43,7 +43,7 @@ void main() { }, ), ), - new Flexible( + new Expanded( child: new Block( padding: new EdgeInsets.symmetric(horizontal: 24.0), children: [ new Text(explanation, textAlign: TextAlign.center) ] diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index fbc61bb3217..c2233e56ef1 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -252,7 +252,7 @@ class AboutDialog extends StatelessWidget { List body = []; if (icon != null) body.add(new IconTheme(data: new IconThemeData(size: 48.0), child: icon)); - body.add(new Flexible( + body.add(new Expanded( child: new Padding( padding: new EdgeInsets.symmetric(horizontal: 24.0), child: new BlockBody( diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 1753293d0fb..1e6a7cc0210 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -311,7 +311,7 @@ class BottomNavigationBarState extends State with TickerPro ); for (int i = 0; i < config.labels.length; i += 1) { children.add( - new Flexible( + new Expanded( child: new InkResponse( onTap: () { if (config.onTap != null) @@ -376,7 +376,7 @@ class BottomNavigationBarState extends State with TickerPro _computeWeight(); for (int i = 0; i < config.labels.length; i += 1) { children.add( - new Flexible( + new Expanded( // Since Flexible only supports integers, we're using large // numbers in order to simulate floating point flex values. flex: (_flex(animations[i]) * 1000.0).round(), diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index 5e34b96b089..cfb87139d11 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -450,7 +450,7 @@ class DataTable extends StatelessWidget { final bool isLightTheme = Theme.of(context).brightness == Brightness.light; if (showEditIcon) { final Widget icon = new Icon(Icons.edit, size: 18.0); - label = new Flexible(child: label); + label = new Expanded(child: label); label = new Row(children: numeric ? [ icon, label ] : [ label, icon ]); } label = new Container( diff --git a/packages/flutter/lib/src/material/drawer_item.dart b/packages/flutter/lib/src/material/drawer_item.dart index 194be348f61..762acff3371 100644 --- a/packages/flutter/lib/src/material/drawer_item.dart +++ b/packages/flutter/lib/src/material/drawer_item.dart @@ -118,7 +118,7 @@ class DrawerItem extends StatelessWidget { } if (child != null) { children.add( - new Flexible( + new Expanded( child: new Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), child: new AnimatedDefaultTextStyle( diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 71992c9fe53..48dd0ec917e 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -116,7 +116,7 @@ class ExpansionPanelList extends StatelessWidget { Row header = new Row( children: [ - new Flexible( + new Expanded( child: new AnimatedContainer( duration: animationDuration, curve: Curves.fastOutSlowIn, diff --git a/packages/flutter/lib/src/material/grid_tile_bar.dart b/packages/flutter/lib/src/material/grid_tile_bar.dart index db72fc79cce..b95bbe47248 100644 --- a/packages/flutter/lib/src/material/grid_tile_bar.dart +++ b/packages/flutter/lib/src/material/grid_tile_bar.dart @@ -81,7 +81,7 @@ class GridTileBar extends StatelessWidget { ); if (title != null && subtitle != null) { children.add( - new Flexible( + new Expanded( child: new Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, @@ -104,7 +104,7 @@ class GridTileBar extends StatelessWidget { ); } else if (title != null || subtitle != null) { children.add( - new Flexible( + new Expanded( child: new DefaultTextStyle( style: darkTheme.textTheme.subhead, softWrap: false, diff --git a/packages/flutter/lib/src/material/input.dart b/packages/flutter/lib/src/material/input.dart index 5fd1ece11ba..6e52e609239 100644 --- a/packages/flutter/lib/src/material/input.dart +++ b/packages/flutter/lib/src/material/input.dart @@ -344,7 +344,7 @@ class _InputContainerState extends State { child: config.icon ) ), - new Flexible(child: textField) + new Expanded(child: textField) ] ); } diff --git a/packages/flutter/lib/src/material/list_item.dart b/packages/flutter/lib/src/material/list_item.dart index d5c9ccd2fe7..89279c7e596 100644 --- a/packages/flutter/lib/src/material/list_item.dart +++ b/packages/flutter/lib/src/material/list_item.dart @@ -190,7 +190,7 @@ class ListItem extends StatelessWidget { ] ); } - children.add(new Flexible( + children.add(new Expanded( child: center )); diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index d08b334d0d4..81baf0e9316 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -273,7 +273,7 @@ class PaginatedDataTableState extends State { final List headerWidgets = []; double leftPadding = 24.0; if (_selectedRowCount == 0) { - headerWidgets.add(new Flexible(child: config.header)); + headerWidgets.add(new Expanded(child: config.header)); if (config.header is ButtonBar) { // We adjust the padding when a button bar is present, because the // ButtonBar introduces 2 pixels of outside padding, plus 2 pixels @@ -285,9 +285,9 @@ class PaginatedDataTableState extends State { } } else if (_selectedRowCount == 1) { // TODO(ianh): Real l10n. - headerWidgets.add(new Flexible(child: new Text('1 item selected'))); + headerWidgets.add(new Expanded(child: new Text('1 item selected'))); } else { - headerWidgets.add(new Flexible(child: new Text('$_selectedRowCount items selected'))); + headerWidgets.add(new Expanded(child: new Text('$_selectedRowCount items selected'))); } if (config.actions != null) { headerWidgets.addAll( diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index 0ec1f0f7d38..fffb2dce683 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -163,7 +163,7 @@ class SnackBar extends StatelessWidget { ); List children = [ const SizedBox(width: _kSnackBarPadding), - new Flexible( + new Expanded( child: new Container( padding: const EdgeInsets.symmetric(vertical: _kSingleLineVerticalPadding), child: new DefaultTextStyle( diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index 0eb77656b50..f968b7dafde 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -576,7 +576,7 @@ class _StepperState extends State with TickerProviderStateMixin { if (!_isLast(i)) children.add( - new Flexible( + new Expanded( child: new Container( margin: const EdgeInsets.symmetric(horizontal: 8.0), height: 1.0, @@ -599,7 +599,7 @@ class _StepperState extends State with TickerProviderStateMixin { ) ) ), - new Flexible( + new Expanded( child: new ScrollableViewport( child: new Container( margin: const EdgeInsets.all(24.0), diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index a7c75201101..92c9e5e84d1 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -717,7 +717,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ header, - new Flexible(child: picker), + new Expanded(child: picker), actions, ] ) @@ -735,7 +735,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { fit: FlexFit.loose, child: new Column( children: [ - new Flexible(child: picker), + new Expanded(child: picker), actions, ] ) diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index 8c6af727472..dc0c75d16b7 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -77,7 +77,7 @@ class _UserAccountsDrawerHeaderState extends State { decoration: config.decoration, child: new Column( children: [ - new Flexible( + new Expanded( child: new Stack( children: [ new Positioned( @@ -137,7 +137,7 @@ class _UserAccountsDrawerHeaderState extends State { style: const TextStyle(color: Colors.white), child: config.accountEmail ), - new Flexible( + new Expanded( child: new Align( alignment: FractionalOffset.centerRight, child: new Icon( diff --git a/packages/flutter/lib/src/rendering/flex.dart b/packages/flutter/lib/src/rendering/flex.dart index c524fb14b90..dc61000ee4e 100644 --- a/packages/flutter/lib/src/rendering/flex.dart +++ b/packages/flutter/lib/src/rendering/flex.dart @@ -107,22 +107,42 @@ enum CrossAxisAlignment { typedef double _ChildSizingFunction(RenderBox child, double extent); -/// Implements the flex layout algorithm +/// Displays its children in a one-dimensional array. /// -/// In flex layout, children are arranged linearly along the main axis (either -/// horizontally or vertically). First, inflexible children (those with a null -/// flex factor) are allocated space along the main axis. If the flex is given -/// unlimited space in the main axis, the flex sizes its main axis to the total -/// size of the inflexible children along the main axis and forbids flexible -/// children. Otherwise, the flex expands to the maximum max-axis size and the -/// remaining space along is divided among the flexible children according to -/// their flex factors. Any remaining free space (i.e., if there aren't any -/// flexible children or some of the flexible children have a loose fit) is -/// allocated according to the [mainAxisAlignment] property. +/// Layout for a [RenderFlex] proceeds in six steps: /// -/// In the cross axis, children determine their own size. The flex then sizes -/// its cross axis to fix the largest of its children. The children are then -/// positioned along the cross axis according to the [crossAxisAlignment] property. +/// 1. Layout each child a null or zero flex factor with unbounded main axis +/// constraints and the incoming cross axis constraints. If the +/// [crossAxisAlignment] is [CrossAxisAlignment.stretch], instead use tight +/// cross axis constraints that match the incoming max extent in the cross +/// axis. +/// 2. Divide the remaining main axis space among the children with non-zero +/// flex factors according to their flex factor. For example, a child with a +/// flex factor of 2.0 will receive twice the amount of main axis space as a +/// child with a flex factor of 1.0. +/// 3. Layout each of the remaining children with the same cross axis +/// constraints as in step 1, but instead of using unbounded main axis +/// constraints, use max axis constraints based on the amount of space +/// allocated in step 2. Children with [Flexible.fit] properties that are +/// [FlexFit.tight] are given tight constraints (i.e., forced to fill the +/// allocated space), and children with [Flexible.fit] properties that are +/// [FlexFit.loose] are given loose constraints (i.e., not forced to fill the +/// allocated space). +/// 4. The cross axis extent of the [RenderFlex] is the maximum cross axis +/// extent of the children (which will always satisfy the incoming +/// constraints). +/// 5. The main axis extent of the [RenderFlex] is determined by the +/// [mainAxisSize] property. If the [mainAxisSize] property is +/// [MainAxisSize.max], then the main axis extent of the [RenderFlex] is the +/// max extent of the incoming main axis constraints. If the [mainAxisSize] +/// property is [MainAxisSize.min], then the main axis extent of the [Flex] +/// is the sum of the main axis extents of the children (subject to the +/// incoming constraints). +/// 6. Determine the position for each child according to the +/// [mainAxisAlignment] and the [crossAxisAlignment]. For example, if the +/// [mainAxisAlignment] is [MainAxisAlignment.spaceBetween], any main axis +/// space that has not been allocated to children is divided evenly and +/// placed between the children. class RenderFlex extends RenderBox with ContainerRenderObjectMixin, RenderBoxContainerDefaultsMixin { /// Creates a flex render object. diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 65fa55642db..185d475c3b8 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1932,32 +1932,16 @@ class GridPlacementData extends ParentDataWidget extends ParentDataWidget { Key key, this.flex: 1, this.fit: FlexFit.tight, - @required Widget child + @required Widget child, }) : super(key: key, child: child); /// The flex factor to use for this child @@ -2212,6 +2274,29 @@ class Flexible extends ParentDataWidget { } } +/// A widget that expands a child of a [Row], [Column], or [Flex]. +/// +/// Using an [Expanded] widget to make a child of a [Row], [Column], or [Flex] +/// expand to fill the available space in the main axis (e.g., horizontally for +/// a [Row] or vertically for a [Column]). If multiple children are expanded, +/// the available space is divided amoung them according to the [flex] factor. +/// +/// An [Expanded] widget must be a descendant of a [Row], [Column], or [Flex], +/// and the path from the [Flexible] widget to its enclosing [Row], [Column], or +/// [Flex] must contain only [StatelessWidget]s or [StatefulWidget]s (not other +/// kinds of widgets, like [RenderObjectWidget]s). +class Expanded extends Flexible { + /// Creates a widget that expands a child of a [Row], [Column], or [Flex] + /// expand to fill the available space in the main axis. + Expanded({ + Key key, + int flex: 1, + @required Widget child, + }) : super(key: key, flex: flex, fit: FlexFit.tight, child: child) { + assert(flex > 0); + } +} + /// A widget that implements the flow layout algorithm. /// /// Flow layouts are optimized for repositioning children using transformation diff --git a/packages/flutter/test/widgets/clamp_overscrolls_test.dart b/packages/flutter/test/widgets/clamp_overscrolls_test.dart index bab9ea8f7c5..5ec9c32cfe5 100644 --- a/packages/flutter/test/widgets/clamp_overscrolls_test.dart +++ b/packages/flutter/test/widgets/clamp_overscrolls_test.dart @@ -22,7 +22,7 @@ Widget buildFrame(ScrollableEdge clampedEdge) { crossAxisAlignment: CrossAxisAlignment.start, children: [ new SizedBox(height: 100.0, child: new Text('top')), - new Flexible(child: new Container()), + new Expanded(child: new Container()), new SizedBox(height: 100.0, child: new Text('bottom')), ] ) diff --git a/packages/flutter/test/widgets/column_test.dart b/packages/flutter/test/widgets/column_test.dart index ae6cee2d3b4..c12b8bd9040 100644 --- a/packages/flutter/test/widgets/column_test.dart +++ b/packages/flutter/test/widgets/column_test.dart @@ -21,7 +21,7 @@ void main() { key: columnKey, children: [ new Container(key: child0Key, width: 100.0, height: 100.0), - new Flexible(child: new Container(key: child1Key, width: 100.0, height: 100.0)), + new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0)), new Container(key: child2Key, width: 100.0, height: 100.0), ] ) diff --git a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart index fce354f5ad0..a7ffa2da7bf 100644 --- a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart @@ -56,10 +56,10 @@ class Wrapper extends StatelessWidget { void main() { testWidgets('Applying parent data inside a LayoutBuilder', (WidgetTester tester) async { - int frame = 0; + int frame = 1; await tester.pumpWidget(new SizeChanger( // when this is triggered, the child LayoutBuilder will build again child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { - return new Column(children: [new Flexible( + return new Column(children: [new Expanded( flex: frame, // this is different after the next pump, so that the parentData has to be applied again child: new Container(height: 100.0), )]); diff --git a/packages/flutter/test/widgets/row_test.dart b/packages/flutter/test/widgets/row_test.dart index 8ef3dab9008..2c4ddf2d229 100644 --- a/packages/flutter/test/widgets/row_test.dart +++ b/packages/flutter/test/widgets/row_test.dart @@ -21,7 +21,7 @@ void main() { key: rowKey, children: [ new Container(key: child0Key, width: 100.0, height: 100.0), - new Flexible(child: new Container(key: child1Key, width: 100.0, height: 100.0)), + new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0)), new Container(key: child2Key, width: 100.0, height: 100.0), ] ) diff --git a/packages/flutter_markdown/lib/src/markdown_raw.dart b/packages/flutter_markdown/lib/src/markdown_raw.dart index 2672ce6cf90..b26a7eee1db 100644 --- a/packages/flutter_markdown/lib/src/markdown_raw.dart +++ b/packages/flutter_markdown/lib/src/markdown_raw.dart @@ -410,7 +410,7 @@ class _Block { width: listIndents.length * markdownStyle.listIndent, child: bullet ), - new Flexible(child: contents) + new Expanded(child: contents) ] ); }