diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index bf19b3a6ba1..3e75cd15bfa 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -203,7 +203,7 @@ class AboutDialog extends StatelessWidget { this.applicationVersion, this.applicationIcon, this.applicationLegalese, - this.children + this.children, }) : super(key: key); /// The name of the application. diff --git a/packages/flutter/lib/src/material/button_bar.dart b/packages/flutter/lib/src/material/button_bar.dart index 710c7ed0f34..306d2a32b42 100644 --- a/packages/flutter/lib/src/material/button_bar.dart +++ b/packages/flutter/lib/src/material/button_bar.dart @@ -30,7 +30,7 @@ class ButtonBar extends StatelessWidget { Key key, this.alignment: MainAxisAlignment.end, this.mainAxisSize: MainAxisSize.max, - this.children + this.children: const [], }) : super(key: key); /// How the children should be placed along the horizontal axis. diff --git a/packages/flutter/lib/src/material/list.dart b/packages/flutter/lib/src/material/list.dart index d91d12616cd..ff647e5d351 100644 --- a/packages/flutter/lib/src/material/list.dart +++ b/packages/flutter/lib/src/material/list.dart @@ -68,7 +68,7 @@ class MaterialList extends StatelessWidget { this.onScroll, this.onScrollEnd, this.type: MaterialListType.twoLine, - this.children, + this.children: const [], this.padding: EdgeInsets.zero, this.scrollableKey }) : super(key: key); diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index c57dae6eb47..568feb31c9c 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'package:flutter/widgets.dart'; +import 'package:meta/meta.dart'; import 'colors.dart'; import 'icon.dart'; @@ -32,7 +33,7 @@ class TwoLevelListItem extends StatelessWidget { TwoLevelListItem({ Key key, this.leading, - this.title, + @required this.title, this.trailing, this.enabled: true, this.onTap, @@ -107,10 +108,10 @@ class TwoLevelSublist extends StatefulWidget { TwoLevelSublist({ Key key, this.leading, - this.title, + @required this.title, this.backgroundColor, this.onOpenChanged, - this.children + this.children: const [], }) : super(key: key); /// A widget to display before the title. @@ -263,7 +264,7 @@ class TwoLevelList extends StatelessWidget { TwoLevelList({ Key key, this.scrollableKey, - this.children, + this.children: const [], this.type: MaterialListType.twoLine, this.padding }) : super(key: key) { diff --git a/packages/flutter/lib/src/rendering/grid.dart b/packages/flutter/lib/src/rendering/grid.dart index ef0e8d6a64e..a37dab49641 100644 --- a/packages/flutter/lib/src/rendering/grid.dart +++ b/packages/flutter/lib/src/rendering/grid.dart @@ -532,6 +532,10 @@ class RenderGrid extends RenderVirtualViewport { /// The delegate that controls the layout of the children. /// + /// For example, a [FixedColumnCountGridDelegate] for grids that have a fixed + /// number of columns or a [MaxTileWidthGridDelegate] for grids that have a + /// maximum tile width. + /// /// If the new delegate is the same as the previous one, this does nothing. /// /// If the new delegate is the same class as the previous one, then the new diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 0ca09edf56d..7a4317e3fa3 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -745,8 +745,6 @@ class LayoutId extends ParentDataWidget { } } -const List _emptyWidgetList = const []; - /// A widget that defers the layout of multiple children to a delegate. /// /// The delegate can determine the layout constraints for each child and can @@ -767,7 +765,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget { CustomMultiChildLayout({ Key key, @required this.delegate, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(delegate != null); } @@ -1414,7 +1412,7 @@ class BlockBody extends MultiChildRenderObjectWidget { BlockBody({ Key key, this.mainAxis: Axis.vertical, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(mainAxis != null); } @@ -1468,7 +1466,7 @@ class Stack extends MultiChildRenderObjectWidget { Key key, this.alignment: FractionalOffset.topLeft, this.overflow: Overflow.clip, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children); /// How to align the non-positioned children in the stack. @@ -1514,7 +1512,7 @@ class IndexedStack extends Stack { Key key, FractionalOffset alignment: FractionalOffset.topLeft, this.index: 0, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, alignment: alignment, children: children) { assert(index != null); } @@ -1710,8 +1708,8 @@ class Positioned extends ParentDataWidget { abstract class GridRenderObjectWidget extends MultiChildRenderObjectWidget { /// Initializes fields for subclasses. GridRenderObjectWidget({ - List children: _emptyWidgetList, - Key key + Key key, + List children: const [], }) : super(key: key, children: children) { _delegate = createDelegate(); } @@ -1743,12 +1741,16 @@ class CustomGrid extends GridRenderObjectWidget { CustomGrid({ Key key, @required this.delegate, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(delegate != null); } /// The delegate that controls the layout of the children. + /// + /// For example, a [FixedColumnCountGridDelegate] for grids that have a fixed + /// number of columns or a [MaxTileWidthGridDelegate] for grids that have a + /// maximum tile width. final GridDelegate delegate; @override @@ -1769,7 +1771,7 @@ class FixedColumnCountGrid extends GridRenderObjectWidget { this.rowSpacing: 0.0, this.tileAspectRatio: 1.0, this.padding: EdgeInsets.zero, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(columnCount != null && columnCount >= 0); assert(tileAspectRatio != null && tileAspectRatio > 0.0); @@ -1816,7 +1818,7 @@ class MaxTileWidthGrid extends GridRenderObjectWidget { this.rowSpacing: 0.0, this.tileAspectRatio: 1.0, this.padding: EdgeInsets.zero, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(maxTileWidth != null && maxTileWidth >= 0.0); assert(tileAspectRatio != null && tileAspectRatio > 0.0); @@ -1945,7 +1947,7 @@ class Flex extends MultiChildRenderObjectWidget { this.mainAxisSize: MainAxisSize.max, this.crossAxisAlignment: CrossAxisAlignment.center, this.textBaseline, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(direction != null); assert(mainAxisAlignment != null); @@ -2047,7 +2049,7 @@ class Row extends Flex { MainAxisSize mainAxisSize: MainAxisSize.max, CrossAxisAlignment crossAxisAlignment: CrossAxisAlignment.center, TextBaseline textBaseline, - List children: _emptyWidgetList + List children: const [], }) : super( children: children, key: key, @@ -2101,7 +2103,7 @@ class Column extends Flex { MainAxisSize mainAxisSize: MainAxisSize.max, CrossAxisAlignment crossAxisAlignment: CrossAxisAlignment.center, TextBaseline textBaseline, - List children: _emptyWidgetList + List children: const [], }) : super( children: children, key: key, @@ -2212,7 +2214,7 @@ class Flow extends MultiChildRenderObjectWidget { Flow({ Key key, @required this.delegate, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: RepaintBoundary.wrapAll(children)) { assert(delegate != null); } @@ -2227,7 +2229,7 @@ class Flow extends MultiChildRenderObjectWidget { Flow.unwrapped({ Key key, this.delegate, - List children: _emptyWidgetList + List children: const [], }) : super(key: key, children: children) { assert(delegate != null); } diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 0ae1d08ded6..7eb040056a1 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1215,7 +1215,7 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget { /// /// The [children] argument must not be null and must not contain any null /// objects. - MultiChildRenderObjectWidget({ Key key, this.children }) + MultiChildRenderObjectWidget({ Key key, this.children: const [] }) : super(key: key) { assert(children != null); assert(!children.any((Widget child) => child == null)); diff --git a/packages/flutter/lib/src/widgets/lazy_block.dart b/packages/flutter/lib/src/widgets/lazy_block.dart index 36308b98870..1ad847bb1ed 100644 --- a/packages/flutter/lib/src/widgets/lazy_block.dart +++ b/packages/flutter/lib/src/widgets/lazy_block.dart @@ -144,7 +144,7 @@ class LazyBlockChildren extends LazyBlockDelegate { /// /// The list of children must not be modified after being passed to this /// constructor. - LazyBlockChildren({ this.children }) { + LazyBlockChildren({ this.children: const [] }) { assert(children != null); } diff --git a/packages/flutter/lib/src/widgets/pageable_list.dart b/packages/flutter/lib/src/widgets/pageable_list.dart index 53c411ae02e..e7911f13381 100644 --- a/packages/flutter/lib/src/widgets/pageable_list.dart +++ b/packages/flutter/lib/src/widgets/pageable_list.dart @@ -122,7 +122,7 @@ class PageableList extends Pageable { ValueChanged onPageChanged, Duration duration: const Duration(milliseconds: 200), Curve curve: Curves.ease, - this.children + this.children: const [], }) : super( key: key, initialScrollOffset: initialScrollOffset, @@ -542,7 +542,7 @@ class PageViewport extends _VirtualPageViewport with VirtualViewportFromIterable Axis mainAxis: Axis.vertical, ViewportAnchor anchor: ViewportAnchor.start, bool itemsWrap: false, - this.children + this.children: const [], }) : super( startOffset, mainAxis, diff --git a/packages/flutter/lib/src/widgets/scrollable_grid.dart b/packages/flutter/lib/src/widgets/scrollable_grid.dart index 7ab22438f72..8e1588446c5 100644 --- a/packages/flutter/lib/src/widgets/scrollable_grid.dart +++ b/packages/flutter/lib/src/widgets/scrollable_grid.dart @@ -35,7 +35,7 @@ class ScrollableGrid extends StatelessWidget { this.snapOffsetCallback, this.scrollableKey, @required this.delegate, - this.children + this.children: const [], }) : super(key: key) { assert(delegate != null); } @@ -75,6 +75,10 @@ class ScrollableGrid extends StatelessWidget { final Key scrollableKey; /// The delegate that controls the layout of the children. + /// + /// For example, a [FixedColumnCountGridDelegate] for grids that have a fixed + /// number of columns or a [MaxTileWidthGridDelegate] for grids that have a + /// maximum tile width. final GridDelegate delegate; /// The children that will be placed in the grid. @@ -124,7 +128,7 @@ class GridViewport extends VirtualViewportFromIterable { this.scrollOffset, this.delegate, this.onExtentsChanged, - this.children + this.children: const [], }) { assert(delegate != null); } @@ -140,6 +144,10 @@ class GridViewport extends VirtualViewportFromIterable { } /// The delegate that controls the layout of the children. + /// + /// For example, a [FixedColumnCountGridDelegate] for grids that have a fixed + /// number of columns or a [MaxTileWidthGridDelegate] for grids that have a + /// maximum tile width. final GridDelegate delegate; /// Called when the interior or exterior dimensions of the viewport change. diff --git a/packages/flutter/lib/src/widgets/scrollable_list.dart b/packages/flutter/lib/src/widgets/scrollable_list.dart index 076a32e0487..30b39fa0422 100644 --- a/packages/flutter/lib/src/widgets/scrollable_list.dart +++ b/packages/flutter/lib/src/widgets/scrollable_list.dart @@ -49,7 +49,7 @@ class ScrollableList extends StatelessWidget { @required this.itemExtent, this.itemsWrap: false, this.padding, - this.children + this.children: const [], }) : super(key: key) { assert(scrollDirection != null); assert(scrollAnchor != null); @@ -389,7 +389,7 @@ class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable @required double itemExtent, bool itemsWrap: false, EdgeInsets padding, - this.children + this.children: const [], }) : super( onExtentsChanged, scrollOffset, diff --git a/packages/flutter/test/material/button_bar_test.dart b/packages/flutter/test/material/button_bar_test.dart new file mode 100644 index 00000000000..479ee2d55d7 --- /dev/null +++ b/packages/flutter/test/material/button_bar_test.dart @@ -0,0 +1,12 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ButtonBar default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new ButtonBar())); + }); +} diff --git a/packages/flutter/test/material/list_test.dart b/packages/flutter/test/material/list_test.dart new file mode 100644 index 00000000000..d86e7c60ffe --- /dev/null +++ b/packages/flutter/test/material/list_test.dart @@ -0,0 +1,12 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('MaterialList default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new MaterialList())); + }); +} diff --git a/packages/flutter/test/material/two_level_list_test.dart b/packages/flutter/test/material/two_level_list_test.dart index bb8cd9b65cd..bce5ea4e28e 100644 --- a/packages/flutter/test/material/two_level_list_test.dart +++ b/packages/flutter/test/material/two_level_list_test.dart @@ -7,7 +7,25 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/material.dart'; void main() { - testWidgets('TwoLeveList basics', (WidgetTester tester) async { + testWidgets('TwoLevelList default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new TwoLevelList())); + + await tester.pumpWidget( + new Material( + child: new Center( + child: new TwoLevelList( + children: [ + new TwoLevelSublist( + title: new Text('Title'), + ) + ] + ) + ) + ) + ); + }); + + testWidgets('TwoLevelList basics', (WidgetTester tester) async { final Key topKey = new UniqueKey(); final Key sublistKey = new UniqueKey(); final Key bottomKey = new UniqueKey(); diff --git a/packages/flutter/test/widget/pageable_list_test.dart b/packages/flutter/test/widget/pageable_list_test.dart index 89ab688f328..122af47d5ac 100644 --- a/packages/flutter/test/widget/pageable_list_test.dart +++ b/packages/flutter/test/widget/pageable_list_test.dart @@ -60,6 +60,10 @@ Future pageRight(WidgetTester tester) { } void main() { + testWidgets('PageableList default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new PageableList())); + }); + testWidgets('PageableList with itemsWrap: false', (WidgetTester tester) async { currentPage = null; await tester.pumpWidget(buildFrame()); diff --git a/packages/flutter/test/widget/scrollable_grid_test.dart b/packages/flutter/test/widget/scrollable_grid_test.dart index 7f7fd32b6c5..7c7463884e6 100644 --- a/packages/flutter/test/widget/scrollable_grid_test.dart +++ b/packages/flutter/test/widget/scrollable_grid_test.dart @@ -7,6 +7,12 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/rendering.dart'; void main() { + testWidgets('ScrollableGrid default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new ScrollableGrid( + delegate: new FixedColumnCountGridDelegate(columnCount: 1), + ))); + }); + // Tests https://github.com/flutter/flutter/issues/5522 testWidgets('ScrollableGrid displays correct children with nonzero padding', (WidgetTester tester) async { GlobalKey scrollableKey = new GlobalKey(); diff --git a/packages/flutter/test/widget/scrollable_list_test.dart b/packages/flutter/test/widget/scrollable_list_test.dart new file mode 100644 index 00000000000..7bf2028d25a --- /dev/null +++ b/packages/flutter/test/widget/scrollable_list_test.dart @@ -0,0 +1,12 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + testWidgets('ScrollableList default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center(child: new ScrollableList(itemExtent: 100.0))); + }); +}