diff --git a/examples/flutter_gallery/lib/demo/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/grid_list_demo.dart index c85aaa19bb..42c0a9e647 100644 --- a/examples/flutter_gallery/lib/demo/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/grid_list_demo.dart @@ -310,9 +310,6 @@ class GridListDemoState extends State { }); } - // When the ScrollableGrid first appears we want the last row to only be - // partially visible, to help the user recognize that the grid is scrollable. - // The GridListDemoGridDelegate's tileHeightFactor is used for this. @override Widget build(BuildContext context) { final Orientation orientation = MediaQuery.of(context).orientation; diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index d611114654..ca8c31b887 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -203,14 +203,12 @@ class GridLists { // START gridlists // Creates a scrollable grid list with images // loaded from the web. -new ScrollableGrid( - delegate: new FixedColumnCountGridDelegate( - columnCount: 3, - tileAspectRatio: 1.0, - padding: const EdgeInsets.all(4.0), - columnSpacing: 4.0, - rowSpacing: 4.0 - ), +new ScrollGrid.count( + crossAxisCount: 3, + childAspectRatio: 1.0, + padding: const EdgeInsets.all(4.0), + mainAxisSpacing: 4.0, + crossAxisSpacing: 4.0, children: [ 'https://example.com/image-0.jpg', 'https://example.com/image-1.jpg', @@ -224,7 +222,7 @@ new ScrollableGrid( ), child: new Image.network(url, fit: ImageFit.cover) ); - }) + }).toList(), ); // END } diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index 07c988aad3..3904f35bee 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart @@ -76,14 +76,14 @@ class AdaptiveContainer extends StatelessWidget { @override Widget build(BuildContext context) { if (MediaQuery.of(context).size.width < _kGridViewBreakpoint) { - return new ScrollableList( + return new ScrollView( itemExtent: _kListItemExtent, - children: names.map((String name) => new AdaptedListItem(name: name)) + children: names.map((String name) => new AdaptedListItem(name: name)).toList(), ); } else { - return new ScrollableGrid( - delegate: new MaxTileWidthGridDelegate(maxTileWidth: _kMaxTileWidth), - children: names.map((String name) => new AdaptedGridItem(name: name)) + return new ScrollGrid.extent( + maxCrossAxisExtent: _kMaxTileWidth, + children: names.map((String name) => new AdaptedGridItem(name: name)).toList(), ); } } diff --git a/packages/flutter/lib/src/material/grid_tile.dart b/packages/flutter/lib/src/material/grid_tile.dart index 729846c347..06446f90b5 100644 --- a/packages/flutter/lib/src/material/grid_tile.dart +++ b/packages/flutter/lib/src/material/grid_tile.dart @@ -4,30 +4,41 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; +import 'package:meta/meta.dart'; /// A tile in a material design grid list. /// -/// A grid list is a [ScrollableGrid] of tiles in a vertical and horizontal +/// A grid list is a [ScrollGrid] of tiles in a vertical and horizontal /// array. Each tile typically contains some visually rich content (e.g., an /// image) together with a [GridTileBar] in either a [header] or a [footer]. /// /// See also: /// -/// * [ScrollableGrid] -/// * [GridTileBar] +/// * [ScrollGrid], which is a scrollable grid of tiles. +/// * [GridTileBar], which is typically used in either the [header] or +/// [footer]. /// * class GridTile extends StatelessWidget { /// Creates a grid tile. /// /// Must have a child. Does not typically have both a header and a footer. - GridTile({ Key key, this.header, this.footer, @required this.child }) : super(key: key) { + GridTile({ + Key key, + this.header, + this.footer, + @required this.child, + }) : super(key: key) { assert(child != null); } /// The widget to show over the top of this grid tile. + /// + /// Typically a [GridTileBar]. final Widget header; /// The widget to show over the bottom of this grid tile. + /// + /// Typically a [GridTileBar]. final Widget footer; /// The widget that fills the tile. diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index 676b49259e..1d98cfe71a 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -28,7 +28,7 @@ class ScrollView extends StatelessWidget { this.scrollDirection: Axis.vertical, this.initialScrollOffset: 0.0, this.itemExtent, - this.children, + this.children: const [], }) : super(key: key); final EdgeInsets padding; @@ -76,7 +76,7 @@ class ScrollGrid extends StatelessWidget { this.scrollDirection: Axis.vertical, this.initialScrollOffset: 0.0, this.gridDelegate, - this.children, + this.children: const [], }) : super(key: key); ScrollGrid.count({ @@ -88,7 +88,7 @@ class ScrollGrid extends StatelessWidget { double mainAxisSpacing: 0.0, double crossAxisSpacing: 0.0, double childAspectRatio: 1.0, - this.children, + this.children: const [], }) : gridDelegate = new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: crossAxisCount, mainAxisSpacing: mainAxisSpacing, @@ -105,7 +105,7 @@ class ScrollGrid extends StatelessWidget { double mainAxisSpacing: 0.0, double crossAxisSpacing: 0.0, double childAspectRatio: 1.0, - this.children, + this.children: const [], }) : gridDelegate = new SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: maxCrossAxisExtent, mainAxisSpacing: mainAxisSpacing, diff --git a/packages/flutter/test/widgets/scrollable_grid_test.dart b/packages/flutter/test/widgets/scrollable_grid_test.dart index c9c9ca361b..c44d204ad6 100644 --- a/packages/flutter/test/widgets/scrollable_grid_test.dart +++ b/packages/flutter/test/widgets/scrollable_grid_test.dart @@ -7,30 +7,30 @@ 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), - ))); + testWidgets('ScrollGrid default control', (WidgetTester tester) async { + await tester.pumpWidget(new Center( + child: new ScrollGrid.count( + crossAxisCount: 1, + ), + )); }); // Tests https://github.com/flutter/flutter/issues/5522 - testWidgets('ScrollableGrid displays correct children with nonzero padding', (WidgetTester tester) async { + testWidgets('ScrollGrid displays correct children with nonzero padding', (WidgetTester tester) async { final EdgeInsets padding = const EdgeInsets.fromLTRB(0.0, 100.0, 0.0, 0.0); Widget testWidget = new Align( child: new SizedBox( height: 800.0, width: 300.0, // forces the grid children to be 300..300 - child: new ScrollableGrid( - delegate: new FixedColumnCountGridDelegate( - columnCount: 1, - padding: padding - ), + child: new ScrollGrid.count( + crossAxisCount: 1, + padding: padding, children: new List.generate(10, (int index) { return new Text('$index', key: new ValueKey(index)); - }) - ) - ) + }).toList(), + ), + ), ); await tester.pumpWidget(testWidget);