Change Block children to be a named parameter

This commit is contained in:
Hans Muller
2016-01-21 16:59:52 -08:00
parent 05f79b4e45
commit 8218ff683f
28 changed files with 85 additions and 69 deletions

View File

@@ -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)
)
)
)

View File

@@ -125,7 +125,7 @@ class _DropDownMenu<T> extends StatusTransitionComponent {
Widget child = new Material(
type: MaterialType.transparency,
child: new Block(children)
child: new Block(children: children)
);
return new FadeTransition(
opacity: opacity,

View File

@@ -86,7 +86,7 @@ class _PopupMenu<T> extends StatelessComponent {
child: new IntrinsicWidth(
stepWidth: _kMenuWidthStep,
child: new Block(
children,
children: children,
padding: const EdgeDims.symmetric(
vertical: _kMenuVerticalPadding
)

View File

@@ -155,5 +155,5 @@ class TwoLevelList extends StatelessComponent {
final List<Widget> items;
final MaterialListType type;
Widget build(BuildContext context) => new Block(items);
Widget build(BuildContext context) => new Block(children: items);
}

View File

@@ -436,8 +436,9 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
/// 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,

View File

@@ -12,13 +12,15 @@ void main() {
test('Cannot scroll a non-overflowing block', () {
testWidgets((WidgetTester tester) {
tester.pumpWidget(
new Block(<Widget>[
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: <Widget>[
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(<Widget>[
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: <Widget>[
new Container(
height: 2000.0, // more than 600, the height of the test area
child: new Text('Hello')
)
]
)
);
tester.pump(); // for SizeObservers

View File

@@ -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(<Widget>[new Center()]));
tester.pumpWidget(new Block(children: <Widget>[new Center()]));
});
});
}

View File

@@ -12,16 +12,18 @@ void main() {
DateTime currentValue;
Widget widget = new Material(
child: new Block(<Widget>[
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: <Widget>[
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);

View File

@@ -14,7 +14,7 @@ Key thirdKey = new Key('third');
final Map<String, RouteBuilder> routes = <String, RouteBuilder>{
'/': (RouteArguments args) => new Material(
child: new Block([
child: new Block(children: <Widget>[
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<String, RouteBuilder> routes = <String, RouteBuilder>{
])
),
'/two': (RouteArguments args) => new Material(
child: new Block([
child: new Block(children: <Widget>[
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<String, RouteBuilder> routes = <String, RouteBuilder>{
class ThreeRoute extends MaterialPageRoute {
ThreeRoute() : super(builder: (BuildContext context) {
return new Material(
child: new Block([
child: new Block(children: <Widget>[
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),

View File

@@ -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(<Widget>[new LinearProgressIndicator(value: 0.0)]));
tester.pumpWidget(new Block(children: <Widget>[new LinearProgressIndicator(value: 0.0)]));
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;
expect(layers1, isNot(equals(layers2)));