Use a named argument for Widget children

Previously we used a positional argument for widgets that had multiple
children. Now we use a named argument that defaults to an empty list.

Fixes #241
This commit is contained in:
Adam Barth
2016-01-11 13:08:47 -08:00
parent 26db7a2d95
commit 056766414c
69 changed files with 1444 additions and 1143 deletions

View File

@@ -17,7 +17,8 @@ class Field extends StatelessComponent {
final String placeholder;
Widget build(BuildContext context) {
return new Row(<Widget>[
return new Row(
children: <Widget>[
new Padding(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Icon(icon: icon)

View File

@@ -35,7 +35,7 @@ class DialogMenuItem extends StatelessComponent {
onTap: onPressed,
child: new Padding(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Row(children)
child: new Row(children: children)
)
)
);
@@ -163,7 +163,7 @@ class FeedFragmentState extends State<FeedFragment> {
return new Container();
if (config.userData.items.length == 0) {
return new Row(
<Widget>[new Text("No data yet.\nAdd some!", style: style)],
children: <Widget>[new Text("No data yet.\nAdd some!", style: style)],
justifyContent: FlexJustifyContent.center
);
}

View File

@@ -35,7 +35,7 @@ class MealRow extends FitnessItemRow {
)
];
return new Row(
children,
children: children,
alignItems: FlexAlignItems.baseline,
textBaseline: DefaultTextStyle.of(context).textBaseline
);

View File

@@ -47,7 +47,7 @@ class MeasurementRow extends FitnessItemRow {
)
];
return new Row(
children,
children: children,
alignItems: FlexAlignItems.baseline,
textBaseline: DefaultTextStyle.of(context).textBaseline
);
@@ -124,24 +124,30 @@ class MeasurementFragmentState extends State<MeasurementFragment> {
// TODO(jackson): Revisit the layout of this pane to be more maintainable
return new Container(
padding: const EdgeDims.all(20.0),
child: new Column(<Widget>[
new GestureDetector(
onTap: _handleDatePressed,
child: new Container(
height: 50.0,
child: new Column(<Widget>[
new Text('Measurement Date'),
new Text(measurement.displayDate, style: Theme.of(context).text.caption),
], alignItems: FlexAlignItems.start)
)
),
new Input(
key: weightKey,
placeholder: 'Enter weight',
keyboardType: KeyboardType.NUMBER,
onChanged: _handleWeightChanged
),
], alignItems: FlexAlignItems.stretch)
child: new Column(
children: <Widget>[
new GestureDetector(
onTap: _handleDatePressed,
child: new Container(
height: 50.0,
child: new Column(
children: <Widget>[
new Text('Measurement Date'),
new Text(measurement.displayDate, style: Theme.of(context).text.caption),
],
alignItems: FlexAlignItems.start
)
)
),
new Input(
key: weightKey,
placeholder: 'Enter weight',
keyboardType: KeyboardType.NUMBER,
onChanged: _handleWeightChanged
),
],
alignItems: FlexAlignItems.stretch
)
);
}

View File

@@ -89,14 +89,17 @@ class SettingsFragmentState extends State<SettingsFragment> {
return new Block(<Widget>[
new DrawerItem(
onPressed: () { _handleBackupChanged(!(config.userData.backupMode == BackupMode.enabled)); },
child: new Row(<Widget>[
new Flexible(child: new Text('Back up data to the cloud')),
new Switch(value: config.userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged),
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Back up data to the cloud')),
new Switch(value: config.userData.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged),
]
)
),
new DrawerItem(
onPressed: () => _handleGoalWeightPressed(),
child: new Column(<Widget>[
child: new Column(
children: <Widget>[
new Text('Goal Weight'),
new Text(goalWeightText, style: Theme.of(context).text.caption),
],

View File

@@ -31,13 +31,16 @@ class _DatePickerDemoState extends State<DatePickerDemo> {
}
Widget build(BuildContext context) {
return new Column([
new Text(new DateFormat.yMMMd().format(_selectedDate)),
new RaisedButton(
onPressed: _handleSelectDate,
child: new Text('SELECT DATE')
),
], justifyContent: FlexJustifyContent.center);
return new Column(
children: <Widget>[
new Text(new DateFormat.yMMMd().format(_selectedDate)),
new RaisedButton(
onPressed: _handleSelectDate,
child: new Text('SELECT DATE')
),
],
justifyContent: FlexJustifyContent.center
);
}
}

View File

@@ -65,31 +65,35 @@ class TabViewDemo extends StatelessComponent {
values: _iconNames,
child: new Builder(
builder: (BuildContext context) {
return new Column([
new Container(
margin: const EdgeDims.only(top: 16.0),
child: new Row(<Widget>[
new IconButton(
icon: "navigation/arrow_back",
onPressed: () { _handleArrowButtonPress(context, -1); }
),
new Row(
_iconNames.map((String name) => _buildTabIndicator(context, name)).toList(),
justifyContent: FlexJustifyContent.collapse
),
new IconButton(
icon: "navigation/arrow_forward",
onPressed: () { _handleArrowButtonPress(context, 1); }
)],
justifyContent: FlexJustifyContent.spaceBetween
return new Column(
children: <Widget>[
new Container(
margin: const EdgeDims.only(top: 16.0),
child: new Row(
children: <Widget>[
new IconButton(
icon: "navigation/arrow_back",
onPressed: () { _handleArrowButtonPress(context, -1); }
),
new Row(
children: _iconNames.map((String name) => _buildTabIndicator(context, name)).toList(),
justifyContent: FlexJustifyContent.collapse
),
new IconButton(
icon: "navigation/arrow_forward",
onPressed: () { _handleArrowButtonPress(context, 1); }
)
],
justifyContent: FlexJustifyContent.spaceBetween
)
),
new Flexible(
child: new TabBarView(
children: _iconNames.map(_buildTabView).toList()
)
)
),
new Flexible(
child: new TabBarView(
children: _iconNames.map(_buildTabView).toList()
)
)
]);
]
);
}
)
);

View File

@@ -34,28 +34,43 @@ class _SelectionControlsDemoState extends State<SelectionControlsDemo> {
}
Widget build(BuildContext context) {
return new Column(<Widget>[
new Row(<Widget>[
new Checkbox(value: _checkboxValue, onChanged: _setCheckboxValue),
new Checkbox(value: false), // Disabled
new Checkbox(value: true), // Disabled
], justifyContent: FlexJustifyContent.spaceAround),
new Row(<int>[0, 1, 2].map((int i) {
return new Radio<int>(
value: i,
groupValue: _radioValue,
onChanged: _setRadioValue
);
}).toList(), justifyContent: FlexJustifyContent.spaceAround),
new Row(<int>[0, 1].map((int i) {
return new Radio<int>(value: i, groupValue: 0); // Disabled
}).toList(), justifyContent: FlexJustifyContent.spaceAround),
new Row(<Widget>[
new Switch(value: _switchValue, onChanged: _setSwitchValue),
new Switch(value: false), // Disabled
new Switch(value: true), // Disabled
], justifyContent: FlexJustifyContent.spaceAround),
], justifyContent: FlexJustifyContent.spaceAround);
return new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Checkbox(value: _checkboxValue, onChanged: _setCheckboxValue),
new Checkbox(value: false), // Disabled
new Checkbox(value: true), // Disabled
],
justifyContent: FlexJustifyContent.spaceAround
),
new Row(
children: <int>[0, 1, 2].map((int i) {
return new Radio<int>(
value: i,
groupValue: _radioValue,
onChanged: _setRadioValue
);
}).toList(),
justifyContent: FlexJustifyContent.spaceAround
),
new Row(
children: <int>[0, 1].map((int i) {
return new Radio<int>(value: i, groupValue: 0); // Disabled
}).toList(),
justifyContent: FlexJustifyContent.spaceAround
),
new Row(
children: <Widget>[
new Switch(value: _switchValue, onChanged: _setSwitchValue),
new Switch(value: false), // Disabled
new Switch(value: true), // Disabled
],
justifyContent: FlexJustifyContent.spaceAround
),
],
justifyContent: FlexJustifyContent.spaceAround
);
}
}

View File

@@ -18,35 +18,41 @@ class _SliderDemoState extends State<SliderDemo> {
new Container(
height: 100.0,
child: new Center(
child: new Row([
new Slider(
value: _value,
min: 0.0,
max: 100.0,
onChanged: (double value) {
setState(() {
_value = value;
});
}
),
new Container(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Text(_value.round().toString().padLeft(3, '0'))
),
], justifyContent: FlexJustifyContent.collapse)
child: new Row(
children: <Widget>[
new Slider(
value: _value,
min: 0.0,
max: 100.0,
onChanged: (double value) {
setState(() {
_value = value;
});
}
),
new Container(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Text(_value.round().toString().padLeft(3, '0'))
),
],
justifyContent: FlexJustifyContent.collapse
)
)
),
new Container(
height: 100.0,
child: new Center(
child: new Row([
// Disabled, but tracking the slider above.
new Slider(value: _value / 100.0),
new Container(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Text((_value / 100.0).toStringAsFixed(2))
),
], justifyContent: FlexJustifyContent.collapse)
child: new Row(
children: <Widget>[
// Disabled, but tracking the slider above.
new Slider(value: _value / 100.0),
new Container(
padding: const EdgeDims.symmetric(horizontal: 16.0),
child: new Text((_value / 100.0).toStringAsFixed(2))
),
],
justifyContent: FlexJustifyContent.collapse
)
)
)

View File

@@ -28,13 +28,16 @@ class _TimePickerDemoState extends State<TimePickerDemo> {
}
Widget build(BuildContext context) {
return new Column([
new Text('$_selectedTime'),
new RaisedButton(
onPressed: _handleSelectTime,
child: new Text('SELECT TIME')
),
], justifyContent: FlexJustifyContent.center);
return new Column(
children: <Widget>[
new Text('$_selectedTime'),
new RaisedButton(
onPressed: _handleSelectTime,
child: new Text('SELECT TIME')
),
],
justifyContent: FlexJustifyContent.center
);
}
}

View File

@@ -33,17 +33,19 @@ class _GalleryPageState extends State<GalleryPage> {
// TODO(eseidel): We should make this into a shared DrawerFooter.
items.add(new DrawerDivider());
items.add(new DrawerItem(child: new Flex([
new Text("Made with Flutter "),
new Container(
margin: const EdgeDims.symmetric(horizontal: 5.0),
child: new AssetImage(
name: 'assets/flutter_logo.png',
height: 16.0,
fit: ImageFit.contain
items.add(new DrawerItem(child: new Flex(
children: <Widget>[
new Text("Made with Flutter "),
new Container(
margin: const EdgeDims.symmetric(horizontal: 5.0),
child: new AssetImage(
name: 'assets/flutter_logo.png',
height: 16.0,
fit: ImageFit.contain
)
)
)
])));
]
)));
return new Drawer(child: new Block(items));
}

View File

@@ -139,7 +139,7 @@ class MineDiggerState extends State<MineDigger> {
}
flexRows.add(
new Row(
row,
children: row,
justifyContent: FlexJustifyContent.center,
key: new ValueKey<int>(iy)
)
@@ -157,7 +157,7 @@ class MineDiggerState extends State<MineDigger> {
padding: new EdgeDims.all(10.0),
margin: new EdgeDims.all(10.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFF6B6B6B)),
child: new Column(flexRows)
child: new Column(children: flexRows)
);
}

View File

@@ -114,18 +114,22 @@ class StockHomeState extends State<StockHome> {
new DrawerItem(
icon: 'action/thumb_up',
onPressed: () => _handleStockModeChange(StockMode.optimistic),
child: new Row(<Widget>[
new Flexible(child: new Text('Optimistic')),
new Radio<StockMode>(value: StockMode.optimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Optimistic')),
new Radio<StockMode>(value: StockMode.optimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange)
]
)
),
new DrawerItem(
icon: 'action/thumb_down',
onPressed: () => _handleStockModeChange(StockMode.pessimistic),
child: new Row(<Widget>[
new Flexible(child: new Text('Pessimistic')),
new Radio<StockMode>(value: StockMode.pessimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Pessimistic')),
new Radio<StockMode>(value: StockMode.pessimistic, groupValue: config.configuration.stockMode, onChanged: _handleStockModeChange)
]
)
),
new DrawerDivider(),
new DrawerItem(
@@ -241,12 +245,14 @@ class StockHomeState extends State<StockHome> {
// TODO(ianh): Fill this out.
context: context,
builder: (BuildContext context) {
return new Column([
new Input(
key: companyNameKey,
placeholder: 'Company Name'
),
]);
return new Column(
children: <Widget>[
new Input(
key: companyNameKey,
placeholder: 'Company Name'
),
]
);
}
);
}

View File

@@ -19,7 +19,8 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
items: <PopupMenuItem>[
new PopupMenuItem(
value: _MenuItems.autorefresh,
child: new Row(<Widget>[
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Autorefresh')),
new StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
@@ -75,16 +76,18 @@ Future showStockMenu({BuildContext context, bool autorefresh, ValueChanged<bool>
content: new Text('This feature has not yet been implemented.'),
actions: <Widget>[
new FlatButton(
child: new Row(<Widget>[
new Icon(
icon: 'device/dvr',
size: IconSize.s18
),
new Container(
width: 8.0
),
new Text('DUMP APP TO CONSOLE'),
]),
child: new Row(
children: <Widget>[
new Icon(
icon: 'device/dvr',
size: IconSize.s18
),
new Container(
width: 8.0
),
new Text('DUMP APP TO CONSOLE'),
]
),
onPressed: () { debugDumpApp(); }
),
new FlatButton(

View File

@@ -67,7 +67,8 @@ class StockRow extends StatelessComponent {
bottom: new BorderSide(color: Theme.of(context).dividerColor)
)
),
child: new Row(<Widget>[
child: new Row(
children: <Widget>[
new Container(
margin: const EdgeDims.only(right: 5.0),
child: new Hero(
@@ -77,7 +78,8 @@ class StockRow extends StatelessComponent {
)
),
new Flexible(
child: new Row(<Widget>[
child: new Row(
children: <Widget>[
new Flexible(
flex: 2,
child: new Text(

View File

@@ -82,35 +82,41 @@ class StockSettingsState extends State<StockSettings> {
new DrawerItem(
icon: 'action/thumb_up',
onPressed: () => _confirmOptimismChange(),
child: new Row(<Widget>[
new Flexible(child: new Text('Everything is awesome')),
new Checkbox(
value: config.configuration.stockMode == StockMode.optimistic,
onChanged: (bool value) => _confirmOptimismChange()
),
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Everything is awesome')),
new Checkbox(
value: config.configuration.stockMode == StockMode.optimistic,
onChanged: (bool value) => _confirmOptimismChange()
),
]
)
),
new DrawerItem(
icon: 'action/backup',
onPressed: () { _handleBackupChanged(!(config.configuration.backupMode == BackupMode.enabled)); },
child: new Row(<Widget>[
new Flexible(child: new Text('Back up stock list to the cloud')),
new Switch(
value: config.configuration.backupMode == BackupMode.enabled,
onChanged: _handleBackupChanged
),
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Back up stock list to the cloud')),
new Switch(
value: config.configuration.backupMode == BackupMode.enabled,
onChanged: _handleBackupChanged
),
]
)
),
new DrawerItem(
icon: 'action/picture_in_picture',
onPressed: () { _handleShowPerformanceOverlayChanged(!config.configuration.showPerformanceOverlay); },
child: new Row(<Widget>[
new Flexible(child: new Text('Show rendering performance overlay')),
new Switch(
value: config.configuration.showPerformanceOverlay,
onChanged: _handleShowPerformanceOverlayChanged
),
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show rendering performance overlay')),
new Switch(
value: config.configuration.showPerformanceOverlay,
onChanged: _handleShowPerformanceOverlayChanged
),
]
)
),
];
assert(() {
@@ -119,24 +125,28 @@ class StockSettingsState extends State<StockSettings> {
new DrawerItem(
icon: 'editor/border_clear',
onPressed: () { _handleShowGridChanged(!config.configuration.debugShowGrid); },
child: new Row(<Widget>[
new Flexible(child: new Text('Show material grid (for debugging)')),
new Switch(
value: config.configuration.debugShowGrid,
onChanged: _handleShowGridChanged
),
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show material grid (for debugging)')),
new Switch(
value: config.configuration.debugShowGrid,
onChanged: _handleShowGridChanged
),
]
)
),
new DrawerItem(
icon: 'editor/border_all',
onPressed: () { _handleShowSizesChanged(!config.configuration.debugShowSizes); },
child: new Row(<Widget>[
new Flexible(child: new Text('Show construction lines (for debugging)')),
new Switch(
value: config.configuration.debugShowSizes,
onChanged: _handleShowSizesChanged
),
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Show construction lines (for debugging)')),
new Switch(
value: config.configuration.debugShowSizes,
onChanged: _handleShowSizesChanged
),
]
)
)
]);
return true;

View File

@@ -18,8 +18,10 @@ class StockSymbolView extends StatelessComponent {
TextStyle headings = Theme.of(context).text.body2;
return new Container(
padding: new EdgeDims.all(20.0),
child: new Column(<Widget>[
new Row(<Widget>[
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Text(
'${stock.symbol}',
style: Theme.of(context).text.display2

View File

@@ -209,13 +209,15 @@ class CardCollectionState extends State<CardCollection> {
Widget buildDrawerCheckbox(String label, bool value, void callback(), { bool enabled: true }) {
return new DrawerItem(
onPressed: enabled ? callback : null,
child: new Row(<Widget>[
new Flexible(child: new Text(label)),
new Checkbox(
value: value,
onChanged: enabled ? (_) { callback(); } : null
)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text(label)),
new Checkbox(
value: value,
onChanged: enabled ? (_) { callback(); } : null
)
]
)
);
}
@@ -223,14 +225,16 @@ class CardCollectionState extends State<CardCollection> {
return new DrawerItem(
icon: icon,
onPressed: enabled ? () { onChanged(itemValue); } : null,
child: new Row(<Widget>[
new Flexible(child: new Text(label)),
new Radio<Map<int, Color>>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null
)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text(label)),
new Radio<Map<int, Color>>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null
)
]
)
);
}
@@ -238,14 +242,16 @@ class CardCollectionState extends State<CardCollection> {
return new DrawerItem(
icon: icon,
onPressed: enabled ? () { onChanged(itemValue); } : null,
child: new Row(<Widget>[
new Flexible(child: new Text(label)),
new Radio<DismissDirection>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null
)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text(label)),
new Radio<DismissDirection>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null
)
]
)
);
}
@@ -253,14 +259,16 @@ class CardCollectionState extends State<CardCollection> {
return new DrawerItem(
icon: icon,
onPressed: enabled ? () { onChanged(itemValue); } : null,
child: new Row(<Widget>[
new Flexible(child: new Text(label)),
new Radio<TextStyle>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null
)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text(label)),
new Radio<TextStyle>(
value: itemValue,
groupValue: currentValue,
onChanged: enabled ? onChanged : null
)
]
)
);
}
@@ -307,7 +315,8 @@ class CardCollectionState extends State<CardCollection> {
style: DefaultTextStyle.of(context).merge(cardLabelStyle).merge(_textStyle).copyWith(
fontSize: _varyFontSizes ? _cardModels.length.toDouble() : null
),
child: new Column(<Widget>[
child: new Column(
children: <Widget>[
new Text(cardModel.label)
],
alignItems: FlexAlignItems.stretch,
@@ -357,11 +366,13 @@ class CardCollectionState extends State<CardCollection> {
child: new Container(
height: cardModel.height,
decoration: new BoxDecoration(backgroundColor: Theme.of(context).primaryColor),
child: new Row(<Widget>[
leftArrowIcon,
new Flexible(child: new Text(backgroundMessage, style: backgroundTextStyle)),
rightArrowIcon
])
child: new Row(
children: <Widget>[
leftArrowIcon,
new Flexible(child: new Text(backgroundMessage, style: backgroundTextStyle)),
rightArrowIcon
]
)
)
)
)
@@ -370,7 +381,7 @@ class CardCollectionState extends State<CardCollection> {
return new IconTheme(
key: cardModel.key,
data: const IconThemeData(color: IconThemeColor.white),
child: new Stack(<Widget>[background, card])
child: new Stack(children: <Widget>[background, card])
);
}
@@ -409,11 +420,14 @@ class CardCollectionState extends State<CardCollection> {
);
}
if (_sunshine)
cardCollection = new Stack(<Widget>[
new Column(<Widget>[new NetworkImage(src: _sunshineURL)]),
new ShaderMask(child: cardCollection, shaderCallback: _createShader)
]);
if (_sunshine) {
cardCollection = new Stack(
children: <Widget>[
new Column(children: <Widget>[new NetworkImage(src: _sunshineURL)]),
new ShaderMask(child: cardCollection, shaderCallback: _createShader)
]
);
}
Widget body = new SizeObserver(
onSizeChanged: _updateCardCollectionSize,
@@ -434,7 +448,7 @@ class CardCollectionState extends State<CardCollection> {
)
)
);
body = new Stack(<Widget>[body, indicator]);
body = new Stack(children: <Widget>[body, indicator]);
}
return new Theme(

View File

@@ -6,7 +6,8 @@ import 'package:flutter/material.dart';
class ContainerApp extends StatelessComponent {
Widget build(BuildContext context) {
return new Column(<Widget>[
return new Column(
children: <Widget>[
new Container(
padding: new EdgeDims.all(10.0),
margin: new EdgeDims.all(10.0),
@@ -20,15 +21,17 @@ class ContainerApp extends StatelessComponent {
new Container(
decoration: new BoxDecoration(backgroundColor: const Color(0xFFFFFF00)),
padding: new EdgeDims.symmetric(horizontal: 50.0, vertical: 75.0),
child: new Row(<Widget>[
new RaisedButton(
child: new Text('PRESS ME'),
onPressed: () => print("Hello World")
),
new RaisedButton(
child: new Text('DISABLED')
)
])
child: new Row(
children: <Widget>[
new RaisedButton(
child: new Text('PRESS ME'),
onPressed: () => print("Hello World")
),
new RaisedButton(
child: new Text('DISABLED')
)
]
)
),
new Flexible(
child: new Container(

View File

@@ -135,37 +135,44 @@ class DragAndDropApp extends StatelessComponent {
toolBar: new ToolBar(
center: new Text('Drag and Drop Flutter Demo')
),
body: new Column(<Widget>[
new Flexible(child: new Row(<Widget>[
new ExampleDragSource(
color: const Color(0xFFFFF000),
under: true,
heavy: false,
child: new Text('under')
),
new ExampleDragSource(
color: const Color(0xFF0FFF00),
under: false,
heavy: true,
child: new Text('long-press above')
),
new ExampleDragSource(
color: const Color(0xFF00FFF0),
under: false,
heavy: false,
child: new Text('above')
),
],
alignItems: FlexAlignItems.center,
justifyContent: FlexJustifyContent.spaceAround
)),
new Flexible(child: new Row(<Widget>[
new Flexible(child: new ExampleDragTarget()),
new Flexible(child: new ExampleDragTarget()),
new Flexible(child: new ExampleDragTarget()),
new Flexible(child: new ExampleDragTarget()),
])),
])
body: new Column(
children: <Widget>[
new Flexible(child: new Row(
children: <Widget>[
new ExampleDragSource(
color: const Color(0xFFFFF000),
under: true,
heavy: false,
child: new Text('under')
),
new ExampleDragSource(
color: const Color(0xFF0FFF00),
under: false,
heavy: true,
child: new Text('long-press above')
),
new ExampleDragSource(
color: const Color(0xFF00FFF0),
under: false,
heavy: false,
child: new Text('above')
),
],
alignItems: FlexAlignItems.center,
justifyContent: FlexJustifyContent.spaceAround
)),
new Flexible(
child: new Row(
children: <Widget>[
new Flexible(child: new ExampleDragTarget()),
new Flexible(child: new ExampleDragTarget()),
new Flexible(child: new ExampleDragTarget()),
new Flexible(child: new ExampleDragTarget()),
]
)
),
]
)
);
}
}

View File

@@ -138,68 +138,79 @@ class ScaleAppState extends State<ScaleApp> {
child: new Scaffold(
toolBar: new ToolBar(
center: new Text('Gestures Demo')),
body: new Stack([
new GestureDetector(
onScaleStart: _scaleEnabled ? _handleScaleStart : null,
onScaleUpdate: _scaleEnabled ? _handleScaleUpdate : null,
onTap: _tapEnabled ? _handleColorChange : null,
onDoubleTap: _doubleTapEnabled ? _handleScaleReset : null,
onLongPress: _longPressEnabled ? _handleDirectionChange : null,
child: new CustomPaint(
painter: new _GesturePainter(
zoom: _zoom,
offset: _offset,
swatch: _swatch,
forward: _forward,
scaleEnabled: _scaleEnabled,
tapEnabled: _tapEnabled,
doubleTapEnabled: _doubleTapEnabled,
longPressEnabled: _longPressEnabled
)
)
),
new Positioned(
bottom: 0.0,
left: 0.0,
child: new Card(
child: new Container(
padding: new EdgeDims.all(4.0),
child: new Column([
new Row([
new Checkbox(
value: _scaleEnabled,
onChanged: (bool value) { setState(() { _scaleEnabled = value; }); }
),
new Text('Scale'),
]),
new Row([
new Checkbox(
value: _tapEnabled,
onChanged: (bool value) { setState(() { _tapEnabled = value; }); }
),
new Text('Tap'),
]),
new Row([
new Checkbox(
value: _doubleTapEnabled,
onChanged: (bool value) { setState(() { _doubleTapEnabled = value; }); }
),
new Text('Double Tap'),
]),
new Row([
new Checkbox(
value: _longPressEnabled,
onChanged: (bool value) { setState(() { _longPressEnabled = value; }); }
),
new Text('Long Press'),
]),
],
alignItems: FlexAlignItems.start
body: new Stack(
children: <Widget>[
new GestureDetector(
onScaleStart: _scaleEnabled ? _handleScaleStart : null,
onScaleUpdate: _scaleEnabled ? _handleScaleUpdate : null,
onTap: _tapEnabled ? _handleColorChange : null,
onDoubleTap: _doubleTapEnabled ? _handleScaleReset : null,
onLongPress: _longPressEnabled ? _handleDirectionChange : null,
child: new CustomPaint(
painter: new _GesturePainter(
zoom: _zoom,
offset: _offset,
swatch: _swatch,
forward: _forward,
scaleEnabled: _scaleEnabled,
tapEnabled: _tapEnabled,
doubleTapEnabled: _doubleTapEnabled,
longPressEnabled: _longPressEnabled
)
)
)
),
])
),
new Positioned(
bottom: 0.0,
left: 0.0,
child: new Card(
child: new Container(
padding: new EdgeDims.all(4.0),
child: new Column(
children: <Widget>[
new Row(
children: <Widget>[
new Checkbox(
value: _scaleEnabled,
onChanged: (bool value) { setState(() { _scaleEnabled = value; }); }
),
new Text('Scale'),
]
),
new Row(
children: <Widget>[
new Checkbox(
value: _tapEnabled,
onChanged: (bool value) { setState(() { _tapEnabled = value; }); }
),
new Text('Tap'),
]
),
new Row(
children: <Widget>[
new Checkbox(
value: _doubleTapEnabled,
onChanged: (bool value) { setState(() { _doubleTapEnabled = value; }); }
),
new Text('Double Tap'),
]
),
new Row(
children: <Widget>[
new Checkbox(
value: _longPressEnabled,
onChanged: (bool value) { setState(() { _longPressEnabled = value; }); }
),
new Text('Long Press'),
]
),
],
alignItems: FlexAlignItems.start
)
)
)
),
]
)
)
);
}

View File

@@ -59,20 +59,22 @@ class HeroDemo extends StatelessComponent {
child: new GestureDetector(
onTap: () => Navigator.push(context, new CrabRoute()),
child: new Card(
child: new Row(<Widget>[
new HeroImage(
size: const Size(100.0, 100.0)
),
new Flexible(
child: new Container(
padding: const EdgeDims.all(10.0),
child: new Text(
"Low Crab Diet",
style: Theme.of(context).text.title
child: new Row(
children: <Widget>[
new HeroImage(
size: const Size(100.0, 100.0)
),
new Flexible(
child: new Container(
padding: const EdgeDims.all(10.0),
child: new Text(
"Low Crab Diet",
style: Theme.of(context).text.title
)
)
)
)
])
]
)
)
)
)
@@ -94,34 +96,39 @@ class CrabPage extends StatelessComponent {
color: const Color(0x00000000),
child: new Block(
<Widget>[
new Stack(<Widget>[
new HeroImage(
size: new Size(ui.window.size.width, ui.window.size.width)
),
new ToolBar(
padding: new EdgeDims.only(top: ui.window.padding.top),
backgroundColor: const Color(0x00000000),
left: new IconButton(
icon: "navigation/arrow_back",
onPressed: () => Navigator.pop(context)
new Stack(
children: <Widget>[
new HeroImage(
size: new Size(ui.window.size.width, ui.window.size.width)
),
right: <Widget>[
new IconButton(icon: "navigation/more_vert")
]
),
new Positioned(
bottom: 10.0,
left: 10.0,
child: new Text("Low Crab Diet", style: titleStyle)
)
]),
new ToolBar(
padding: new EdgeDims.only(top: ui.window.padding.top),
backgroundColor: const Color(0x00000000),
left: new IconButton(
icon: "navigation/arrow_back",
onPressed: () => Navigator.pop(context)
),
right: <Widget>[
new IconButton(icon: "navigation/more_vert")
]
),
new Positioned(
bottom: 10.0,
left: 10.0,
child: new Text("Low Crab Diet", style: titleStyle)
)
]
),
new Material(
child: new Container(
padding: const EdgeDims.all(10.0),
child: new Column(<Widget>[
new Text(kText, style: Theme.of(context).text.body1),
new Container(height: 800.0),
], alignItems: FlexAlignItems.start)
child: new Column(
children: <Widget>[
new Text(kText, style: Theme.of(context).text.body1),
new Container(height: 800.0),
],
alignItems: FlexAlignItems.start
)
)
)
]

View File

@@ -30,7 +30,7 @@ class IndexedStackDemoState extends State<IndexedStackDemo> {
Widget build(BuildContext context) {
List<PopupMenuItem> items = _buildMenu();
IndexedStack indexedStack = new IndexedStack(items, index: _itemIndex, alignment: const FractionalOffset(0.5, 0.0));
IndexedStack indexedStack = new IndexedStack(children: items, index: _itemIndex, alignment: const FractionalOffset(0.5, 0.0));
return new Scaffold(
toolBar: new ToolBar(center: new Text('IndexedStackDemo Demo')),

View File

@@ -17,7 +17,7 @@ class AdaptiveItem {
Widget toListItem() {
return new Row(
<Widget>[
children: <Widget>[
new Container(
width: 32.0,
height: 32.0,
@@ -34,7 +34,7 @@ class AdaptiveItem {
Widget toCard() {
return new Card(
child: new Column(
<Widget>[
children: <Widget>[
new Flexible(
child: new Container(
decoration: new BoxDecoration(
@@ -45,7 +45,7 @@ class AdaptiveItem {
new Container(
margin: const EdgeDims.only(left: 8.0),
child: new Row(
<Widget>[
children: <Widget>[
new Flexible(
child: new Text(name)
),

View File

@@ -169,7 +169,7 @@ class OverlayGeometryAppState extends State<OverlayGeometryApp> {
];
for (MarkerType type in markers.keys)
layers.add(new Marker(type: type, position: markers[type]));
return new Stack(layers);
return new Stack(children: layers);
}
}

View File

@@ -95,10 +95,12 @@ class PageableListAppState extends State<PageableListApp> {
),
new DrawerItem(
onPressed: toggleItemsWrap,
child: new Row(<Widget>[
new Flexible(child: new Text('Scrolling wraps around')),
new Checkbox(value: itemsWrap)
])
child: new Row(
children: <Widget>[
new Flexible(child: new Text('Scrolling wraps around')),
new Checkbox(value: itemsWrap)
]
)
)
])
);

View File

@@ -88,7 +88,7 @@ class PianoApp extends StatelessComponent {
)
));
}
return new Column(children);
return new Column(children: children);
}
}

View File

@@ -70,7 +70,7 @@ class ProgressIndicatorAppState extends State<ProgressIndicatorApp> {
new Text("${(valueAnimation.value * 100.0).toStringAsFixed(1)}%" + (valueAnimation.isAnimating ? '' : ' (paused)'))
];
return new Column(
indicators
children: indicators
.map((Widget c) => new Container(child: c, margin: const EdgeDims.symmetric(vertical: 15.0, horizontal: 20.0)))
.toList(),
justifyContent: FlexJustifyContent.center

View File

@@ -53,7 +53,8 @@ class HardwareKeyDemoState extends State<HardwareKeyDemo> implements mojo.RawKey
child: new Text("Press a key", style: Typography.black.display1)
);
}
return new Column([
return new Column(
children: <Widget>[
new Text(
'${_event.type}',
style: Typography.black.body2
@@ -62,7 +63,9 @@ class HardwareKeyDemoState extends State<HardwareKeyDemo> implements mojo.RawKey
'${_event.keyData.keyCode}',
style: Typography.black.display4
)
], justifyContent: FlexJustifyContent.center);
],
justifyContent: FlexJustifyContent.center
);
}
Widget build(BuildContext context) {

View File

@@ -68,33 +68,39 @@ class SectorAppState extends State<SectorApp> {
}
Widget buildBody() {
return new Column(<Widget>[
return new Column(
children: <Widget>[
new Container(
padding: new EdgeDims.symmetric(horizontal: 8.0, vertical: 25.0),
child: new Row(<Widget>[
child: new Row(
children: <Widget>[
new RaisedButton(
child: new IntrinsicWidth(
child: new Row(<Widget>[
new Container(
padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(sectorAddIcon)
),
new Text('ADD SECTOR'),
])
child: new Row(
children: <Widget>[
new Container(
padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(sectorAddIcon)
),
new Text('ADD SECTOR'),
]
)
),
onPressed: _enabledAdd ? addSector : null
),
new RaisedButton(
child: new IntrinsicWidth(
child: new Row(<Widget>[
new Container(
padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(sectorRemoveIcon)
),
new Text('REMOVE SECTOR'),
])
child: new Row(
children: <Widget>[
new Container(
padding: new EdgeDims.all(4.0),
margin: new EdgeDims.only(right: 10.0),
child: new WidgetToRenderBoxAdapter(sectorRemoveIcon)
),
new Text('REMOVE SECTOR'),
]
)
),
onPressed: _enabledRemove ? removeSector : null
)

View File

@@ -37,15 +37,18 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
container: container,
child: new Container(
height: 300.0,
child: new Column(<Widget>[
child: new Column(
children: <Widget>[
new Rectangle(const Color(0xFF00FFFF)),
new Container(
padding: new EdgeDims.all(10.0),
margin: new EdgeDims.all(10.0),
decoration: new BoxDecoration(backgroundColor: const Color(0xFFCCCCCC)),
child: new Row(<Widget>[
child: new Row(
children: <Widget>[
new RaisedButton(
child: new Row(<Widget>[
child: new Row(
children: <Widget>[
new NetworkImage(src: "http://flutter.io/favicon.ico"),
new Text('PRESS ME'),
]

View File

@@ -89,7 +89,8 @@ HAL: This mission is too important for me to allow you to jeopardize it.''';
Widget body = new Container(
padding: new EdgeDims.symmetric(horizontal: 8.0),
child: new Column(children,
child: new Column(
children: children,
justifyContent: FlexJustifyContent.center,
alignItems: FlexAlignItems.start
)