From 8218ff683fe9e0b075ceae794b76bbd69144a4c5 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 21 Jan 2016 16:59:52 -0800 Subject: [PATCH] Change Block children to be a named parameter --- examples/address_book/lib/main.dart | 2 +- examples/fitness/lib/feed.dart | 4 +-- examples/fitness/lib/meal.dart | 2 +- examples/fitness/lib/settings.dart | 2 +- .../material_gallery/lib/demo/chip_demo.dart | 14 ++++---- .../lib/demo/slider_demo.dart | 2 +- examples/material_gallery/lib/main.dart | 2 +- examples/stocks/lib/stock_home.dart | 2 +- examples/stocks/lib/stock_settings.dart | 2 +- examples/stocks/lib/stock_symbol_viewer.dart | 14 ++++---- examples/widgets/card_collection.dart | 2 +- examples/widgets/hero_under.dart | 2 +- examples/widgets/horizontal_scrolling.dart | 2 +- examples/widgets/http_post.dart | 10 +++--- examples/widgets/mimic_demo.dart | 2 +- examples/widgets/navigation.dart | 9 ++++-- examples/widgets/pageable_list.dart | 2 +- examples/widgets/smooth_resize.dart | 2 +- packages/flutter/lib/src/material/dialog.dart | 2 +- .../flutter/lib/src/material/dropdown.dart | 2 +- .../flutter/lib/src/material/popup_menu.dart | 2 +- .../lib/src/material/two_level_list.dart | 2 +- .../flutter/lib/src/widgets/scrollable.dart | 3 +- packages/flutter/test/widget/block_test.dart | 32 +++++++++++-------- packages/flutter/test/widget/center_test.dart | 2 +- .../flutter/test/widget/date_picker_test.dart | 22 +++++++------ packages/flutter/test/widget/heroes_test.dart | 6 ++-- .../test/widget/progress_indicator_test.dart | 4 +-- 28 files changed, 85 insertions(+), 69 deletions(-) diff --git a/examples/address_book/lib/main.dart b/examples/address_book/lib/main.dart index 32b846c37c..03c35c5855 100644 --- a/examples/address_book/lib/main.dart +++ b/examples/address_book/lib/main.dart @@ -56,7 +56,7 @@ class AddressBookHome extends StatelessComponent { static final GlobalKey noteKey = new GlobalKey(debugLabel: 'note field'); Widget buildBody(BuildContext context) { - return new Block([ + return new Block(children: [ new AspectRatio( aspectRatio: 16.0 / 9.0, child: new Container( diff --git a/examples/fitness/lib/feed.dart b/examples/fitness/lib/feed.dart index d0f6731f07..74f7dbd005 100644 --- a/examples/fitness/lib/feed.dart +++ b/examples/fitness/lib/feed.dart @@ -64,7 +64,7 @@ class FeedFragmentState extends State { Widget _buildDrawer() { return new Drawer( - child: new Block([ + child: new Block(children: [ new DrawerHeader(child: new Text('Fitness')), new DrawerItem( icon: 'action/view_list', @@ -239,7 +239,7 @@ class AddItemDialogState extends State { } return new Dialog( title: new Text("What are you doing?"), - content: new Block(menuItems), + content: new Block(children: menuItems), actions: [ new FlatButton( child: new Text('CANCEL'), diff --git a/examples/fitness/lib/meal.dart b/examples/fitness/lib/meal.dart index 95bd719674..dbd1bdb2cb 100644 --- a/examples/fitness/lib/meal.dart +++ b/examples/fitness/lib/meal.dart @@ -85,7 +85,7 @@ class MealFragmentState extends State { Widget buildBody() { Meal meal = new Meal(when: new DateTime.now()); - return new Block([ + return new Block(children: [ new Text(meal.displayDate), new Input( key: descriptionKey, diff --git a/examples/fitness/lib/settings.dart b/examples/fitness/lib/settings.dart index 847542c26b..a99544d7b2 100644 --- a/examples/fitness/lib/settings.dart +++ b/examples/fitness/lib/settings.dart @@ -87,7 +87,7 @@ class SettingsFragmentState extends State { } Widget buildSettingsPane(BuildContext context) { - return new Block([ + return new Block(children: [ new DrawerItem( onPressed: () { _handleBackupChanged(!(config.userData.backupMode == BackupMode.enabled)); }, child: new Row( diff --git a/examples/material_gallery/lib/demo/chip_demo.dart b/examples/material_gallery/lib/demo/chip_demo.dart index c29ddd3241..075593ce3e 100644 --- a/examples/material_gallery/lib/demo/chip_demo.dart +++ b/examples/material_gallery/lib/demo/chip_demo.dart @@ -37,12 +37,14 @@ class _ChipDemoState extends State { return new Scaffold( toolBar: new ToolBar(center: new Text("Chips")), - body: new Block(chips.map((Widget widget) { - return new Container( - height: 100.0, - child: new Center(child: widget) - ); - }).toList()) + body: new Block( + children: chips.map((Widget widget) { + return new Container( + height: 100.0, + child: new Center(child: widget) + ); + }).toList() + ) ); } } diff --git a/examples/material_gallery/lib/demo/slider_demo.dart b/examples/material_gallery/lib/demo/slider_demo.dart index c3243aed16..ae17ee1370 100644 --- a/examples/material_gallery/lib/demo/slider_demo.dart +++ b/examples/material_gallery/lib/demo/slider_demo.dart @@ -14,7 +14,7 @@ class _SliderDemoState extends State { Widget build(BuildContext context) { return new Scaffold( toolBar: new ToolBar(center: new Text("Sliders")), - body: new Block([ + body: new Block(children: [ new Container( height: 100.0, child: new Center( diff --git a/examples/material_gallery/lib/main.dart b/examples/material_gallery/lib/main.dart index 10c2ef9985..01d1e5f70c 100644 --- a/examples/material_gallery/lib/main.dart +++ b/examples/material_gallery/lib/main.dart @@ -128,7 +128,7 @@ class GalleryHome extends StatelessComponent { body: new Padding( padding: const EdgeDims.all(4.0), child: new Block( - [ + children: [ new Row( children: [ new GallerySection( diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 81531000bc..6c79e4de14 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -71,7 +71,7 @@ class StockHomeState extends State { Widget _buildDrawer(BuildContext context) { return new Drawer( - child: new Block([ + child: new Block(children: [ new DrawerHeader(child: new Text('Stocks')), new DrawerItem( icon: 'action/assessment', diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 433b7bf2d7..4e83043d10 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -152,7 +152,7 @@ class StockSettingsState extends State { return true; }); return new Block( - rows, + children: rows, padding: const EdgeDims.symmetric(vertical: 20.0) ); } diff --git a/examples/stocks/lib/stock_symbol_viewer.dart b/examples/stocks/lib/stock_symbol_viewer.dart index 62fee6667c..92161a0d8c 100644 --- a/examples/stocks/lib/stock_symbol_viewer.dart +++ b/examples/stocks/lib/stock_symbol_viewer.dart @@ -59,12 +59,14 @@ class StockSymbolPage extends StatelessComponent { toolBar: new ToolBar( center: new Text(stock.name) ), - body: new Block([ - new Container( - margin: new EdgeDims.all(20.0), - child: new Card(child: new StockSymbolView(stock: stock)) - ) - ]) + body: new Block( + children: [ + new Container( + margin: new EdgeDims.all(20.0), + child: new Card(child: new StockSymbolView(stock: stock)) + ) + ] + ) ); } } diff --git a/examples/widgets/card_collection.dart b/examples/widgets/card_collection.dart index a3726b4d1c..34de081e83 100644 --- a/examples/widgets/card_collection.dart +++ b/examples/widgets/card_collection.dart @@ -121,7 +121,7 @@ class CardCollectionState extends State { return new Drawer( child: new IconTheme( data: const IconThemeData(color: IconThemeColor.black), - child: new Block([ + child: new Block(children: [ new DrawerHeader(child: new Text('Options')), buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable), buildDrawerCheckbox("Snap fling scrolls to center", _snapToCenter, _toggleSnapToCenter), diff --git a/examples/widgets/hero_under.dart b/examples/widgets/hero_under.dart index 2d5c8c1f2a..1177f1d660 100644 --- a/examples/widgets/hero_under.dart +++ b/examples/widgets/hero_under.dart @@ -95,7 +95,7 @@ class CrabPage extends StatelessComponent { return new Material( color: const Color(0x00000000), child: new Block( - [ + children: [ new Stack( children: [ new HeroImage( diff --git a/examples/widgets/horizontal_scrolling.dart b/examples/widgets/horizontal_scrolling.dart index 5d6ba04f79..6202028f9b 100644 --- a/examples/widgets/horizontal_scrolling.dart +++ b/examples/widgets/horizontal_scrolling.dart @@ -41,7 +41,7 @@ class HorizontalScrollingApp extends StatelessComponent { return new Center( child: new Container( height: 50.0, - child: new Block(circles, scrollDirection: Axis.horizontal) + child: new Block(children: circles, scrollDirection: Axis.horizontal) ) ); } diff --git a/examples/widgets/http_post.dart b/examples/widgets/http_post.dart index 3664836ce9..2752b2e04b 100644 --- a/examples/widgets/http_post.dart +++ b/examples/widgets/http_post.dart @@ -53,10 +53,12 @@ class PostDemoState extends State { ), body: new Material( child: new Block( - [new Text( - "${_response ?? 'Loading...'}", - style: Typography.black.body1 - )] + children: [ + new Text( + "${_response ?? 'Loading...'}", + style: Typography.black.body1 + ) + ] ) ), floatingActionButton: new FloatingActionButton( diff --git a/examples/widgets/mimic_demo.dart b/examples/widgets/mimic_demo.dart index 1e154ba0db..a901bb4105 100644 --- a/examples/widgets/mimic_demo.dart +++ b/examples/widgets/mimic_demo.dart @@ -88,7 +88,7 @@ class _MimicDemoState extends State { return new GestureDetector( onTap: _handleTap, onLongPress: _reset, - child: new Block(children) + child: new Block(children: children) ); } } diff --git a/examples/widgets/navigation.dart b/examples/widgets/navigation.dart index d9f76a48c7..ae23f24128 100644 --- a/examples/widgets/navigation.dart +++ b/examples/widgets/navigation.dart @@ -8,7 +8,8 @@ class Home extends StatelessComponent { Widget build(BuildContext context) { return new Material( child: new Center( - child: new Block([ + child: new Block( + children: [ new Text( 'You are at home.', style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center) @@ -34,7 +35,8 @@ class Shopping extends StatelessComponent { return new Material( color: Colors.deepPurple[300], child: new Center( - child: new Block([ + child: new Block( + children: [ new Text( 'Village Shop', style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center) @@ -60,7 +62,8 @@ class Adventure extends StatelessComponent { return new Material( color: Colors.red[300], child: new Center( - child: new Block([ + child: new Block( + children: [ new Text( 'Monster\'s Lair', style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center) diff --git a/examples/widgets/pageable_list.dart b/examples/widgets/pageable_list.dart index f1d40f3b7e..5141a91e64 100644 --- a/examples/widgets/pageable_list.dart +++ b/examples/widgets/pageable_list.dart @@ -79,7 +79,7 @@ class PageableListAppState extends State { Widget _buildDrawer() { return new Drawer( - child: new Block([ + child: new Block(children: [ new DrawerHeader(child: new Text('Options')), new DrawerItem( icon: 'navigation/more_horiz', diff --git a/examples/widgets/smooth_resize.dart b/examples/widgets/smooth_resize.dart index 9d4486c86c..3788660021 100644 --- a/examples/widgets/smooth_resize.dart +++ b/examples/widgets/smooth_resize.dart @@ -106,7 +106,7 @@ class SmoothBlockState extends State { class SmoothResizeDemo extends StatelessComponent { Widget build(BuildContext context) { - return new Block(_kColors.map((Map color) => new SmoothBlock(color: color)).toList()); + return new Block(children: _kColors.map((Map color) => new SmoothBlock(color: color)).toList()); } } diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index 77498ca811..18bdfb647c 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -107,7 +107,7 @@ class Dialog extends StatelessComponent { color: _getColor(context), type: MaterialType.card, child: new IntrinsicWidth( - child: new Block(dialogBody) + child: new Block(children: dialogBody) ) ) ) diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index b27aa8a2a5..2596368be6 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -125,7 +125,7 @@ class _DropDownMenu extends StatusTransitionComponent { Widget child = new Material( type: MaterialType.transparency, - child: new Block(children) + child: new Block(children: children) ); return new FadeTransition( opacity: opacity, diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 975388ec80..ce0903a3b5 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -86,7 +86,7 @@ class _PopupMenu extends StatelessComponent { child: new IntrinsicWidth( stepWidth: _kMenuWidthStep, child: new Block( - children, + children: children, padding: const EdgeDims.symmetric( vertical: _kMenuVerticalPadding ) diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index 6af08a6b0c..ffef20a6c4 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -155,5 +155,5 @@ class TwoLevelList extends StatelessComponent { final List items; final MaterialListType type; - Widget build(BuildContext context) => new Block(items); + Widget build(BuildContext context) => new Block(children: items); } diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 3774c37760..f30c50a996 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -436,8 +436,9 @@ class ScrollableViewportState extends ScrollableState { /// fixed number of children that you wish to arrange in a block layout and that /// might exceed the height of its container (and therefore need to scroll). class Block extends StatelessComponent { - Block(this.children, { + Block({ Key key, + this.children, this.padding, this.initialScrollOffset, this.scrollDirection: Axis.vertical, diff --git a/packages/flutter/test/widget/block_test.dart b/packages/flutter/test/widget/block_test.dart index 74f7dc48de..0d66305a3d 100644 --- a/packages/flutter/test/widget/block_test.dart +++ b/packages/flutter/test/widget/block_test.dart @@ -12,13 +12,15 @@ void main() { test('Cannot scroll a non-overflowing block', () { testWidgets((WidgetTester tester) { tester.pumpWidget( - new Block([ - new Container( - height: 200.0, // less than 600, the height of the test area - child: new Text('Hello') - ) - ], - key: blockKey) + new Block( + key: blockKey, + children: [ + new Container( + height: 200.0, // less than 600, the height of the test area + child: new Text('Hello') + ) + ] + ) ); tester.pump(); // for SizeObservers @@ -39,13 +41,15 @@ void main() { test('Can scroll an overflowing block', () { testWidgets((WidgetTester tester) { tester.pumpWidget( - new Block([ - new Container( - height: 2000.0, // more than 600, the height of the test area - child: new Text('Hello') - ) - ], - key: blockKey) + new Block( + key: blockKey, + children: [ + new Container( + height: 2000.0, // more than 600, the height of the test area + child: new Text('Hello') + ) + ] + ) ); tester.pump(); // for SizeObservers diff --git a/packages/flutter/test/widget/center_test.dart b/packages/flutter/test/widget/center_test.dart index 3eb7ce3d01..e19ceab3aa 100644 --- a/packages/flutter/test/widget/center_test.dart +++ b/packages/flutter/test/widget/center_test.dart @@ -9,7 +9,7 @@ import 'package:test/test.dart'; void main() { test('Can be placed in an infinite box', () { testWidgets((WidgetTester tester) { - tester.pumpWidget(new Block([new Center()])); + tester.pumpWidget(new Block(children: [new Center()])); }); }); } diff --git a/packages/flutter/test/widget/date_picker_test.dart b/packages/flutter/test/widget/date_picker_test.dart index e4a89880d5..2a0d059b90 100644 --- a/packages/flutter/test/widget/date_picker_test.dart +++ b/packages/flutter/test/widget/date_picker_test.dart @@ -12,16 +12,18 @@ void main() { DateTime currentValue; Widget widget = new Material( - child: new Block([ - new DatePicker( - selectedDate: new DateTime.utc(2015, 6, 9, 7, 12), - firstDate: new DateTime.utc(2013), - lastDate: new DateTime.utc(2018), - onChanged: (DateTime dateTime) { - currentValue = dateTime; - } - ) - ]) + child: new Block( + children: [ + new DatePicker( + selectedDate: new DateTime.utc(2015, 6, 9, 7, 12), + firstDate: new DateTime.utc(2013), + lastDate: new DateTime.utc(2018), + onChanged: (DateTime dateTime) { + currentValue = dateTime; + } + ) + ] + ) ); tester.pumpWidget(widget); diff --git a/packages/flutter/test/widget/heroes_test.dart b/packages/flutter/test/widget/heroes_test.dart index 0ad97c7030..deefffaf6f 100644 --- a/packages/flutter/test/widget/heroes_test.dart +++ b/packages/flutter/test/widget/heroes_test.dart @@ -14,7 +14,7 @@ Key thirdKey = new Key('third'); final Map routes = { '/': (RouteArguments args) => new Material( - child: new Block([ + child: new Block(children: [ new Container(height: 100.0, width: 100.0), new Card(child: new Hero(tag: 'a', child: new Container(height: 100.0, width: 100.0, key: firstKey))), new Container(height: 100.0, width: 100.0), @@ -22,7 +22,7 @@ final Map routes = { ]) ), '/two': (RouteArguments args) => new Material( - child: new Block([ + child: new Block(children: [ new Container(height: 150.0, width: 150.0), new Card(child: new Hero(tag: 'a', child: new Container(height: 150.0, width: 150.0, key: secondKey))), new Container(height: 150.0, width: 150.0), @@ -34,7 +34,7 @@ final Map routes = { class ThreeRoute extends MaterialPageRoute { ThreeRoute() : super(builder: (BuildContext context) { return new Material( - child: new Block([ + child: new Block(children: [ new Container(height: 200.0, width: 200.0), new Card(child: new Hero(tag: 'a', child: new Container(height: 200.0, width: 200.0, key: thirdKey))), new Container(height: 200.0, width: 200.0), diff --git a/packages/flutter/test/widget/progress_indicator_test.dart b/packages/flutter/test/widget/progress_indicator_test.dart index f19bad9a05..6b35320706 100644 --- a/packages/flutter/test/widget/progress_indicator_test.dart +++ b/packages/flutter/test/widget/progress_indicator_test.dart @@ -10,11 +10,11 @@ import 'package:test/test.dart'; void main() { test('LinearProgressIndicator changes when its value changes', () { testWidgets((WidgetTester tester) { - tester.pumpWidget(new Block([new LinearProgressIndicator(value: 0.0)])); + tester.pumpWidget(new Block(children: [new LinearProgressIndicator(value: 0.0)])); List layers1 = tester.layers; - tester.pumpWidget(new Block([new LinearProgressIndicator(value: 0.5)])); + tester.pumpWidget(new Block(children: [new LinearProgressIndicator(value: 0.5)])); List layers2 = tester.layers; expect(layers1, isNot(equals(layers2)));