Commit 8218ff68 authored by Hans Muller's avatar Hans Muller

Change Block children to be a named parameter

parent 05f79b4e
...@@ -56,7 +56,7 @@ class AddressBookHome extends StatelessComponent { ...@@ -56,7 +56,7 @@ class AddressBookHome extends StatelessComponent {
static final GlobalKey noteKey = new GlobalKey(debugLabel: 'note field'); static final GlobalKey noteKey = new GlobalKey(debugLabel: 'note field');
Widget buildBody(BuildContext context) { Widget buildBody(BuildContext context) {
return new Block(<Widget>[ return new Block(children: <Widget>[
new AspectRatio( new AspectRatio(
aspectRatio: 16.0 / 9.0, aspectRatio: 16.0 / 9.0,
child: new Container( child: new Container(
......
...@@ -64,7 +64,7 @@ class FeedFragmentState extends State<FeedFragment> { ...@@ -64,7 +64,7 @@ class FeedFragmentState extends State<FeedFragment> {
Widget _buildDrawer() { Widget _buildDrawer() {
return new Drawer( return new Drawer(
child: new Block(<Widget>[ child: new Block(children: <Widget>[
new DrawerHeader(child: new Text('Fitness')), new DrawerHeader(child: new Text('Fitness')),
new DrawerItem( new DrawerItem(
icon: 'action/view_list', icon: 'action/view_list',
...@@ -239,7 +239,7 @@ class AddItemDialogState extends State<AddItemDialog> { ...@@ -239,7 +239,7 @@ class AddItemDialogState extends State<AddItemDialog> {
} }
return new Dialog( return new Dialog(
title: new Text("What are you doing?"), title: new Text("What are you doing?"),
content: new Block(menuItems), content: new Block(children: menuItems),
actions: <Widget>[ actions: <Widget>[
new FlatButton( new FlatButton(
child: new Text('CANCEL'), child: new Text('CANCEL'),
......
...@@ -85,7 +85,7 @@ class MealFragmentState extends State<MealFragment> { ...@@ -85,7 +85,7 @@ class MealFragmentState extends State<MealFragment> {
Widget buildBody() { Widget buildBody() {
Meal meal = new Meal(when: new DateTime.now()); Meal meal = new Meal(when: new DateTime.now());
return new Block(<Widget>[ return new Block(children: <Widget>[
new Text(meal.displayDate), new Text(meal.displayDate),
new Input( new Input(
key: descriptionKey, key: descriptionKey,
......
...@@ -87,7 +87,7 @@ class SettingsFragmentState extends State<SettingsFragment> { ...@@ -87,7 +87,7 @@ class SettingsFragmentState extends State<SettingsFragment> {
} }
Widget buildSettingsPane(BuildContext context) { Widget buildSettingsPane(BuildContext context) {
return new Block(<Widget>[ return new Block(children: <Widget>[
new DrawerItem( new DrawerItem(
onPressed: () { _handleBackupChanged(!(config.userData.backupMode == BackupMode.enabled)); }, onPressed: () { _handleBackupChanged(!(config.userData.backupMode == BackupMode.enabled)); },
child: new Row( child: new Row(
......
...@@ -37,12 +37,14 @@ class _ChipDemoState extends State<ChipDemo> { ...@@ -37,12 +37,14 @@ class _ChipDemoState extends State<ChipDemo> {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Chips")), toolBar: new ToolBar(center: new Text("Chips")),
body: new Block(chips.map((Widget widget) { body: new Block(
return new Container( children: chips.map((Widget widget) {
height: 100.0, return new Container(
child: new Center(child: widget) height: 100.0,
); child: new Center(child: widget)
}).toList()) );
}).toList()
)
); );
} }
} }
...@@ -14,7 +14,7 @@ class _SliderDemoState extends State<SliderDemo> { ...@@ -14,7 +14,7 @@ class _SliderDemoState extends State<SliderDemo> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Scaffold( return new Scaffold(
toolBar: new ToolBar(center: new Text("Sliders")), toolBar: new ToolBar(center: new Text("Sliders")),
body: new Block(<Widget>[ body: new Block(children: <Widget>[
new Container( new Container(
height: 100.0, height: 100.0,
child: new Center( child: new Center(
......
...@@ -128,7 +128,7 @@ class GalleryHome extends StatelessComponent { ...@@ -128,7 +128,7 @@ class GalleryHome extends StatelessComponent {
body: new Padding( body: new Padding(
padding: const EdgeDims.all(4.0), padding: const EdgeDims.all(4.0),
child: new Block( child: new Block(
<Widget>[ children: <Widget>[
new Row( new Row(
children: <Widget>[ children: <Widget>[
new GallerySection( new GallerySection(
......
...@@ -71,7 +71,7 @@ class StockHomeState extends State<StockHome> { ...@@ -71,7 +71,7 @@ class StockHomeState extends State<StockHome> {
Widget _buildDrawer(BuildContext context) { Widget _buildDrawer(BuildContext context) {
return new Drawer( return new Drawer(
child: new Block(<Widget>[ child: new Block(children: <Widget>[
new DrawerHeader(child: new Text('Stocks')), new DrawerHeader(child: new Text('Stocks')),
new DrawerItem( new DrawerItem(
icon: 'action/assessment', icon: 'action/assessment',
......
...@@ -152,7 +152,7 @@ class StockSettingsState extends State<StockSettings> { ...@@ -152,7 +152,7 @@ class StockSettingsState extends State<StockSettings> {
return true; return true;
}); });
return new Block( return new Block(
rows, children: rows,
padding: const EdgeDims.symmetric(vertical: 20.0) padding: const EdgeDims.symmetric(vertical: 20.0)
); );
} }
......
...@@ -59,12 +59,14 @@ class StockSymbolPage extends StatelessComponent { ...@@ -59,12 +59,14 @@ class StockSymbolPage extends StatelessComponent {
toolBar: new ToolBar( toolBar: new ToolBar(
center: new Text(stock.name) center: new Text(stock.name)
), ),
body: new Block(<Widget>[ body: new Block(
new Container( children: <Widget>[
margin: new EdgeDims.all(20.0), new Container(
child: new Card(child: new StockSymbolView(stock: stock)) margin: new EdgeDims.all(20.0),
) child: new Card(child: new StockSymbolView(stock: stock))
]) )
]
)
); );
} }
} }
......
...@@ -121,7 +121,7 @@ class CardCollectionState extends State<CardCollection> { ...@@ -121,7 +121,7 @@ class CardCollectionState extends State<CardCollection> {
return new Drawer( return new Drawer(
child: new IconTheme( child: new IconTheme(
data: const IconThemeData(color: IconThemeColor.black), data: const IconThemeData(color: IconThemeColor.black),
child: new Block(<Widget>[ child: new Block(children: <Widget>[
new DrawerHeader(child: new Text('Options')), new DrawerHeader(child: new Text('Options')),
buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable), buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable),
buildDrawerCheckbox("Snap fling scrolls to center", _snapToCenter, _toggleSnapToCenter), buildDrawerCheckbox("Snap fling scrolls to center", _snapToCenter, _toggleSnapToCenter),
......
...@@ -95,7 +95,7 @@ class CrabPage extends StatelessComponent { ...@@ -95,7 +95,7 @@ class CrabPage extends StatelessComponent {
return new Material( return new Material(
color: const Color(0x00000000), color: const Color(0x00000000),
child: new Block( child: new Block(
<Widget>[ children: <Widget>[
new Stack( new Stack(
children: <Widget>[ children: <Widget>[
new HeroImage( new HeroImage(
......
...@@ -41,7 +41,7 @@ class HorizontalScrollingApp extends StatelessComponent { ...@@ -41,7 +41,7 @@ class HorizontalScrollingApp extends StatelessComponent {
return new Center( return new Center(
child: new Container( child: new Container(
height: 50.0, height: 50.0,
child: new Block(circles, scrollDirection: Axis.horizontal) child: new Block(children: circles, scrollDirection: Axis.horizontal)
) )
); );
} }
......
...@@ -53,10 +53,12 @@ class PostDemoState extends State<PostDemo> { ...@@ -53,10 +53,12 @@ class PostDemoState extends State<PostDemo> {
), ),
body: new Material( body: new Material(
child: new Block( child: new Block(
[new Text( children: <Widget>[
"${_response ?? 'Loading...'}", new Text(
style: Typography.black.body1 "${_response ?? 'Loading...'}",
)] style: Typography.black.body1
)
]
) )
), ),
floatingActionButton: new FloatingActionButton( floatingActionButton: new FloatingActionButton(
......
...@@ -88,7 +88,7 @@ class _MimicDemoState extends State<MimicDemo> { ...@@ -88,7 +88,7 @@ class _MimicDemoState extends State<MimicDemo> {
return new GestureDetector( return new GestureDetector(
onTap: _handleTap, onTap: _handleTap,
onLongPress: _reset, onLongPress: _reset,
child: new Block(children) child: new Block(children: children)
); );
} }
} }
......
...@@ -8,7 +8,8 @@ class Home extends StatelessComponent { ...@@ -8,7 +8,8 @@ class Home extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Material( return new Material(
child: new Center( child: new Center(
child: new Block(<Widget>[ child: new Block(
children: <Widget>[
new Text( new Text(
'You are at home.', 'You are at home.',
style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center) style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
...@@ -34,7 +35,8 @@ class Shopping extends StatelessComponent { ...@@ -34,7 +35,8 @@ class Shopping extends StatelessComponent {
return new Material( return new Material(
color: Colors.deepPurple[300], color: Colors.deepPurple[300],
child: new Center( child: new Center(
child: new Block(<Widget>[ child: new Block(
children: <Widget>[
new Text( new Text(
'Village Shop', 'Village Shop',
style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center) style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
...@@ -60,7 +62,8 @@ class Adventure extends StatelessComponent { ...@@ -60,7 +62,8 @@ class Adventure extends StatelessComponent {
return new Material( return new Material(
color: Colors.red[300], color: Colors.red[300],
child: new Center( child: new Center(
child: new Block(<Widget>[ child: new Block(
children: <Widget>[
new Text( new Text(
'Monster\'s Lair', 'Monster\'s Lair',
style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center) style: Theme.of(context).text.display2.copyWith(textAlign: TextAlign.center)
......
...@@ -79,7 +79,7 @@ class PageableListAppState extends State<PageableListApp> { ...@@ -79,7 +79,7 @@ class PageableListAppState extends State<PageableListApp> {
Widget _buildDrawer() { Widget _buildDrawer() {
return new Drawer( return new Drawer(
child: new Block(<Widget>[ child: new Block(children: <Widget>[
new DrawerHeader(child: new Text('Options')), new DrawerHeader(child: new Text('Options')),
new DrawerItem( new DrawerItem(
icon: 'navigation/more_horiz', icon: 'navigation/more_horiz',
......
...@@ -106,7 +106,7 @@ class SmoothBlockState extends State<SmoothBlock> { ...@@ -106,7 +106,7 @@ class SmoothBlockState extends State<SmoothBlock> {
class SmoothResizeDemo extends StatelessComponent { class SmoothResizeDemo extends StatelessComponent {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return new Block(_kColors.map((Map<int, Color> color) => new SmoothBlock(color: color)).toList()); return new Block(children: _kColors.map((Map<int, Color> color) => new SmoothBlock(color: color)).toList());
} }
} }
......
...@@ -107,7 +107,7 @@ class Dialog extends StatelessComponent { ...@@ -107,7 +107,7 @@ class Dialog extends StatelessComponent {
color: _getColor(context), color: _getColor(context),
type: MaterialType.card, type: MaterialType.card,
child: new IntrinsicWidth( child: new IntrinsicWidth(
child: new Block(dialogBody) child: new Block(children: dialogBody)
) )
) )
) )
......
...@@ -125,7 +125,7 @@ class _DropDownMenu<T> extends StatusTransitionComponent { ...@@ -125,7 +125,7 @@ class _DropDownMenu<T> extends StatusTransitionComponent {
Widget child = new Material( Widget child = new Material(
type: MaterialType.transparency, type: MaterialType.transparency,
child: new Block(children) child: new Block(children: children)
); );
return new FadeTransition( return new FadeTransition(
opacity: opacity, opacity: opacity,
......
...@@ -86,7 +86,7 @@ class _PopupMenu<T> extends StatelessComponent { ...@@ -86,7 +86,7 @@ class _PopupMenu<T> extends StatelessComponent {
child: new IntrinsicWidth( child: new IntrinsicWidth(
stepWidth: _kMenuWidthStep, stepWidth: _kMenuWidthStep,
child: new Block( child: new Block(
children, children: children,
padding: const EdgeDims.symmetric( padding: const EdgeDims.symmetric(
vertical: _kMenuVerticalPadding vertical: _kMenuVerticalPadding
) )
......
...@@ -155,5 +155,5 @@ class TwoLevelList extends StatelessComponent { ...@@ -155,5 +155,5 @@ class TwoLevelList extends StatelessComponent {
final List<Widget> items; final List<Widget> items;
final MaterialListType type; final MaterialListType type;
Widget build(BuildContext context) => new Block(items); Widget build(BuildContext context) => new Block(children: items);
} }
...@@ -436,8 +436,9 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> { ...@@ -436,8 +436,9 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
/// fixed number of children that you wish to arrange in a block layout and that /// 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). /// might exceed the height of its container (and therefore need to scroll).
class Block extends StatelessComponent { class Block extends StatelessComponent {
Block(this.children, { Block({
Key key, Key key,
this.children,
this.padding, this.padding,
this.initialScrollOffset, this.initialScrollOffset,
this.scrollDirection: Axis.vertical, this.scrollDirection: Axis.vertical,
......
...@@ -12,13 +12,15 @@ void main() { ...@@ -12,13 +12,15 @@ void main() {
test('Cannot scroll a non-overflowing block', () { test('Cannot scroll a non-overflowing block', () {
testWidgets((WidgetTester tester) { testWidgets((WidgetTester tester) {
tester.pumpWidget( tester.pumpWidget(
new Block(<Widget>[ new Block(
new Container( key: blockKey,
height: 200.0, // less than 600, the height of the test area children: <Widget>[
child: new Text('Hello') new Container(
) height: 200.0, // less than 600, the height of the test area
], child: new Text('Hello')
key: blockKey) )
]
)
); );
tester.pump(); // for SizeObservers tester.pump(); // for SizeObservers
...@@ -39,13 +41,15 @@ void main() { ...@@ -39,13 +41,15 @@ void main() {
test('Can scroll an overflowing block', () { test('Can scroll an overflowing block', () {
testWidgets((WidgetTester tester) { testWidgets((WidgetTester tester) {
tester.pumpWidget( tester.pumpWidget(
new Block(<Widget>[ new Block(
new Container( key: blockKey,
height: 2000.0, // more than 600, the height of the test area children: <Widget>[
child: new Text('Hello') new Container(
) height: 2000.0, // more than 600, the height of the test area
], child: new Text('Hello')
key: blockKey) )
]
)
); );
tester.pump(); // for SizeObservers tester.pump(); // for SizeObservers
......
...@@ -9,7 +9,7 @@ import 'package:test/test.dart'; ...@@ -9,7 +9,7 @@ import 'package:test/test.dart';
void main() { void main() {
test('Can be placed in an infinite box', () { test('Can be placed in an infinite box', () {
testWidgets((WidgetTester tester) { testWidgets((WidgetTester tester) {
tester.pumpWidget(new Block(<Widget>[new Center()])); tester.pumpWidget(new Block(children: <Widget>[new Center()]));
}); });
}); });
} }
...@@ -12,16 +12,18 @@ void main() { ...@@ -12,16 +12,18 @@ void main() {
DateTime currentValue; DateTime currentValue;
Widget widget = new Material( Widget widget = new Material(
child: new Block(<Widget>[ child: new Block(
new DatePicker( children: <Widget>[
selectedDate: new DateTime.utc(2015, 6, 9, 7, 12), new DatePicker(
firstDate: new DateTime.utc(2013), selectedDate: new DateTime.utc(2015, 6, 9, 7, 12),
lastDate: new DateTime.utc(2018), firstDate: new DateTime.utc(2013),
onChanged: (DateTime dateTime) { lastDate: new DateTime.utc(2018),
currentValue = dateTime; onChanged: (DateTime dateTime) {
} currentValue = dateTime;
) }
]) )
]
)
); );
tester.pumpWidget(widget); tester.pumpWidget(widget);
......
...@@ -14,7 +14,7 @@ Key thirdKey = new Key('third'); ...@@ -14,7 +14,7 @@ Key thirdKey = new Key('third');
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
'/': (RouteArguments args) => new Material( '/': (RouteArguments args) => new Material(
child: new Block([ child: new Block(children: <Widget>[
new Container(height: 100.0, width: 100.0), 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 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), new Container(height: 100.0, width: 100.0),
...@@ -22,7 +22,7 @@ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{ ...@@ -22,7 +22,7 @@ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
]) ])
), ),
'/two': (RouteArguments args) => new Material( '/two': (RouteArguments args) => new Material(
child: new Block([ child: new Block(children: <Widget>[
new Container(height: 150.0, width: 150.0), 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 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), new Container(height: 150.0, width: 150.0),
...@@ -34,7 +34,7 @@ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{ ...@@ -34,7 +34,7 @@ final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
class ThreeRoute extends MaterialPageRoute { class ThreeRoute extends MaterialPageRoute {
ThreeRoute() : super(builder: (BuildContext context) { ThreeRoute() : super(builder: (BuildContext context) {
return new Material( return new Material(
child: new Block([ child: new Block(children: <Widget>[
new Container(height: 200.0, width: 200.0), 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 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), new Container(height: 200.0, width: 200.0),
......
...@@ -10,11 +10,11 @@ import 'package:test/test.dart'; ...@@ -10,11 +10,11 @@ import 'package:test/test.dart';
void main() { void main() {
test('LinearProgressIndicator changes when its value changes', () { test('LinearProgressIndicator changes when its value changes', () {
testWidgets((WidgetTester tester) { testWidgets((WidgetTester tester) {
tester.pumpWidget(new Block(<Widget>[new LinearProgressIndicator(value: 0.0)])); tester.pumpWidget(new Block(children: <Widget>[new LinearProgressIndicator(value: 0.0)]));
List<Layer> layers1 = tester.layers; List<Layer> layers1 = tester.layers;
tester.pumpWidget(new Block(<Widget>[new LinearProgressIndicator(value: 0.5)])); tester.pumpWidget(new Block(children: <Widget>[new LinearProgressIndicator(value: 0.5)]));
List<Layer> layers2 = tester.layers; List<Layer> layers2 = tester.layers;
expect(layers1, isNot(equals(layers2))); expect(layers1, isNot(equals(layers2)));
......
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