From 332a23030b87dd500c58d76bacb71cc0cd1fbd28 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Fri, 3 Feb 2017 16:05:43 -0800 Subject: [PATCH] Rename and refactor ScrollView hierarchy (#7865) This prepares us for a CustomScrollView that takes slivers. --- dev/benchmarks/complex_layout/lib/main.dart | 2 +- dev/manual_tests/card_collection.dart | 2 +- dev/manual_tests/pageable_list.dart | 2 +- .../flutter_gallery/lib/demo/cards_demo.dart | 2 +- .../flutter_gallery/lib/demo/chip_demo.dart | 2 +- .../flutter_gallery/lib/demo/colors_demo.dart | 2 +- .../lib/demo/data_table_demo.dart | 2 +- .../flutter_gallery/lib/demo/dialog_demo.dart | 2 +- .../flutter_gallery/lib/demo/drawer_demo.dart | 2 +- .../lib/demo/full_screen_dialog_demo.dart | 2 +- .../lib/demo/grid_list_demo.dart | 2 +- .../lib/demo/leave_behind_demo.dart | 2 +- .../flutter_gallery/lib/demo/list_demo.dart | 2 +- .../flutter_gallery/lib/demo/menu_demo.dart | 2 +- .../lib/demo/snack_bar_demo.dart | 2 +- .../flutter_gallery/lib/demo/tabs_demo.dart | 2 +- .../lib/demo/tooltip_demo.dart | 2 +- .../lib/demo/typography_demo.dart | 2 +- .../flutter_gallery/lib/gallery/drawer.dart | 2 +- .../lib/gallery/example_code.dart | 2 +- examples/layers/widgets/media_query.dart | 4 +- examples/stocks/lib/stock_home.dart | 2 +- examples/stocks/lib/stock_settings.dart | 2 +- .../flutter/lib/src/material/grid_tile.dart | 4 +- .../flutter/lib/src/material/stepper.dart | 2 +- .../lib/src/material/two_level_list.dart | 2 +- .../flutter/lib/src/widgets/scroll_view.dart | 314 ++++++++++++++---- .../src/widgets/single_child_scroll_view.dart | 32 +- .../flutter/test/material/about_test.dart | 2 +- .../flutter/test/material/drawer_test.dart | 2 +- .../flutter/test/material/list_item_test.dart | 2 +- .../material/progress_indicator_test.dart | 4 +- .../flutter/test/material/scrollbar_test.dart | 6 +- .../flutter/test/material/slider_test.dart | 2 +- packages/flutter/test/widgets/block_test.dart | 4 +- .../flutter/test/widgets/center_test.dart | 2 +- .../flutter/test/widgets/container_test.dart | 2 +- .../test/widgets/date_picker_test.dart | 2 +- .../flutter/test/widgets/draggable_test.dart | 4 +- .../flutter/test/widgets/drawer_test.dart | 2 +- packages/flutter/test/widgets/form_test.dart | 2 +- .../flutter/test/widgets/heroes_test.dart | 8 +- packages/flutter/test/widgets/list_test.dart | 12 +- .../test/widgets/reparent_state_test.dart | 2 +- .../test/widgets/scroll_grid_test.dart | 28 +- .../test/widgets/scroll_view_test.dart | 16 +- .../test/widgets/scrollable_dispose_test.dart | 4 +- .../test/widgets/scrollable_grid_test.dart | 8 +- .../test/widgets/semantics_debugger_test.dart | 14 +- 49 files changed, 363 insertions(+), 167 deletions(-) diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index 69096752990..a7dac640398 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -588,7 +588,7 @@ class GalleryDrawer extends StatelessWidget { @override Widget build(BuildContext context) { return new Drawer( - child: new ScrollView( + child: new ListView( children: [ new FancyDrawerHeader(), new DrawerItem( diff --git a/dev/manual_tests/card_collection.dart b/dev/manual_tests/card_collection.dart index aa3c0e8795b..1bb534dd5ed 100644 --- a/dev/manual_tests/card_collection.dart +++ b/dev/manual_tests/card_collection.dart @@ -123,7 +123,7 @@ class CardCollectionState extends State { return new Drawer( child: new IconTheme( data: const IconThemeData(color: Colors.black), - child: new ScrollView( + child: new ListView( children: [ new DrawerHeader(child: new Center(child: new Text('Options'))), buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable), diff --git a/dev/manual_tests/pageable_list.dart b/dev/manual_tests/pageable_list.dart index 5f6a788b05c..ea338b35328 100644 --- a/dev/manual_tests/pageable_list.dart +++ b/dev/manual_tests/pageable_list.dart @@ -84,7 +84,7 @@ class PageableListAppState extends State { Widget _buildDrawer() { return new Drawer( - child: new ScrollView( + child: new ListView( children: [ new DrawerHeader(child: new Center(child: new Text('Options'))), new DrawerItem( diff --git a/examples/flutter_gallery/lib/demo/cards_demo.dart b/examples/flutter_gallery/lib/demo/cards_demo.dart index a7167d721c5..fb1e9e97127 100644 --- a/examples/flutter_gallery/lib/demo/cards_demo.dart +++ b/examples/flutter_gallery/lib/demo/cards_demo.dart @@ -134,7 +134,7 @@ class CardsDemo extends StatelessWidget { appBar: new AppBar( title: new Text('Travel stream') ), - body: new ScrollView( + body: new ListView( itemExtent: TravelDestinationItem.height, padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), children: destinations.map((TravelDestination destination) { diff --git a/examples/flutter_gallery/lib/demo/chip_demo.dart b/examples/flutter_gallery/lib/demo/chip_demo.dart index 118f874a20d..162f5c9f551 100644 --- a/examples/flutter_gallery/lib/demo/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/chip_demo.dart @@ -41,7 +41,7 @@ class _ChipDemoState extends State { return new Scaffold( appBar: new AppBar(title: new Text('Chips')), - body: new ScrollView( + body: new ListView( children: chips.map((Widget widget) { return new Container( height: 100.0, diff --git a/examples/flutter_gallery/lib/demo/colors_demo.dart b/examples/flutter_gallery/lib/demo/colors_demo.dart index fabb70ebfd6..95cdac6e63f 100644 --- a/examples/flutter_gallery/lib/demo/colors_demo.dart +++ b/examples/flutter_gallery/lib/demo/colors_demo.dart @@ -98,7 +98,7 @@ class ColorSwatchTabView extends StatelessWidget { }).toList()); } - return new ScrollView( + return new ListView( itemExtent: kColorItemHeight, children: colorItems, ); diff --git a/examples/flutter_gallery/lib/demo/data_table_demo.dart b/examples/flutter_gallery/lib/demo/data_table_demo.dart index e53c3ae0a98..b17bb6d4999 100644 --- a/examples/flutter_gallery/lib/demo/data_table_demo.dart +++ b/examples/flutter_gallery/lib/demo/data_table_demo.dart @@ -165,7 +165,7 @@ class _DataTableDemoState extends State { Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar(title: new Text('Data tables')), - body: new ScrollView( + body: new ListView( padding: const EdgeInsets.all(20.0), children: [ new PaginatedDataTable( diff --git a/examples/flutter_gallery/lib/demo/dialog_demo.dart b/examples/flutter_gallery/lib/demo/dialog_demo.dart index c69af1f95ca..9c5b761556c 100644 --- a/examples/flutter_gallery/lib/demo/dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/dialog_demo.dart @@ -89,7 +89,7 @@ class DialogDemoState extends State { appBar: new AppBar( title: new Text('Dialogs') ), - body: new ScrollView( + body: new ListView( padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0), children: [ new RaisedButton( diff --git a/examples/flutter_gallery/lib/demo/drawer_demo.dart b/examples/flutter_gallery/lib/demo/drawer_demo.dart index 68e973244c7..25987b66f8e 100644 --- a/examples/flutter_gallery/lib/demo/drawer_demo.dart +++ b/examples/flutter_gallery/lib/demo/drawer_demo.dart @@ -88,7 +88,7 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { title: new Text('Navigation drawer'), ), drawer: new Drawer( - child: new ScrollView( + child: new ListView( children: [ new UserAccountsDrawerHeader( accountName: new Text('Zach Widget'), diff --git a/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart b/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart index e5199029d21..60e5f41ce49 100644 --- a/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart @@ -157,7 +157,7 @@ class FullScreenDialogDemoState extends State { ) ] ), - body: new ScrollView( + body: new ListView( padding: const EdgeInsets.all(16.0), children: [ new Container( diff --git a/examples/flutter_gallery/lib/demo/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/grid_list_demo.dart index 42c0a9e647b..4f50bc2cb5a 100644 --- a/examples/flutter_gallery/lib/demo/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/grid_list_demo.dart @@ -339,7 +339,7 @@ class GridListDemoState extends State { body: new Column( children: [ new Expanded( - child: new ScrollGrid.count( + child: new GridView.count( crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3, mainAxisSpacing: 4.0, crossAxisSpacing: 4.0, diff --git a/examples/flutter_gallery/lib/demo/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/leave_behind_demo.dart index 704f8fe9edc..8cd3af1d4df 100644 --- a/examples/flutter_gallery/lib/demo/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/leave_behind_demo.dart @@ -161,7 +161,7 @@ class LeaveBehindDemoState extends State { ) ] ), - body: new ScrollView( + body: new ListView( children: leaveBehindItems.map(buildItem).toList() ) ); diff --git a/examples/flutter_gallery/lib/demo/list_demo.dart b/examples/flutter_gallery/lib/demo/list_demo.dart index b802d3a2d5b..905de7cde0f 100644 --- a/examples/flutter_gallery/lib/demo/list_demo.dart +++ b/examples/flutter_gallery/lib/demo/list_demo.dart @@ -40,7 +40,7 @@ class ListDemoState extends State { decoration: new BoxDecoration( border: new Border(top: new BorderSide(color: Colors.black26)) ), - child: new ScrollView( + child: new ListView( shrinkWrap: true, children: [ new ListItem( diff --git a/examples/flutter_gallery/lib/demo/menu_demo.dart b/examples/flutter_gallery/lib/demo/menu_demo.dart index 4e7e9adab81..082262925ae 100644 --- a/examples/flutter_gallery/lib/demo/menu_demo.dart +++ b/examples/flutter_gallery/lib/demo/menu_demo.dart @@ -83,7 +83,7 @@ class MenuDemoState extends State { ) ] ), - body: new ScrollView( + body: new ListView( padding: const EdgeInsets.symmetric(vertical: 8.0), children: [ // Pressing the PopupMenuButton on the right of this item shows diff --git a/examples/flutter_gallery/lib/demo/snack_bar_demo.dart b/examples/flutter_gallery/lib/demo/snack_bar_demo.dart index 56786cf6628..dfc2fe8e485 100644 --- a/examples/flutter_gallery/lib/demo/snack_bar_demo.dart +++ b/examples/flutter_gallery/lib/demo/snack_bar_demo.dart @@ -29,7 +29,7 @@ class _SnackBarDemoState extends State { int _snackBarIndex = 1; Widget buildBody(BuildContext context) { - return new ScrollView( + return new ListView( padding: const EdgeInsets.all(24.0), children: [ new Text(_text1), diff --git a/examples/flutter_gallery/lib/demo/tabs_demo.dart b/examples/flutter_gallery/lib/demo/tabs_demo.dart index 617ef1e24e3..6e41931435a 100644 --- a/examples/flutter_gallery/lib/demo/tabs_demo.dart +++ b/examples/flutter_gallery/lib/demo/tabs_demo.dart @@ -127,7 +127,7 @@ class TabsDemo extends StatelessWidget { ), body: new TabBarView( children: _allPages.keys.map((_Page page) { - return new ScrollView( + return new ListView( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0), itemExtent: _CardDataItem.height, children: _allPages[page].map((_CardData data) { diff --git a/examples/flutter_gallery/lib/demo/tooltip_demo.dart b/examples/flutter_gallery/lib/demo/tooltip_demo.dart index d264fcd0420..2e1dddd2521 100644 --- a/examples/flutter_gallery/lib/demo/tooltip_demo.dart +++ b/examples/flutter_gallery/lib/demo/tooltip_demo.dart @@ -22,7 +22,7 @@ class TooltipDemo extends StatelessWidget { ), body: new Builder( builder: (BuildContext context) { - return new ScrollView( + return new ListView( children: [ new Text(_introText, style: theme.textTheme.subhead), new Row( diff --git a/examples/flutter_gallery/lib/demo/typography_demo.dart b/examples/flutter_gallery/lib/demo/typography_demo.dart index 2daa1a8040c..b2304ceaf80 100644 --- a/examples/flutter_gallery/lib/demo/typography_demo.dart +++ b/examples/flutter_gallery/lib/demo/typography_demo.dart @@ -66,7 +66,7 @@ class TypographyDemo extends StatelessWidget { return new Scaffold( appBar: new AppBar(title: new Text('Typography')), - body: new ScrollView(children: styleItems) + body: new ListView(children: styleItems) ); } } diff --git a/examples/flutter_gallery/lib/gallery/drawer.dart b/examples/flutter_gallery/lib/gallery/drawer.dart index 280b48846f9..aee84fb7e71 100644 --- a/examples/flutter_gallery/lib/gallery/drawer.dart +++ b/examples/flutter_gallery/lib/gallery/drawer.dart @@ -305,6 +305,6 @@ class GalleryDrawer extends StatelessWidget { )); } - return new Drawer(child: new ScrollView(children: allDrawerItems)); + return new Drawer(child: new ListView(children: allDrawerItems)); } } diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index ca8c31b887d..6dcb8378d94 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -203,7 +203,7 @@ class GridLists { // START gridlists // Creates a scrollable grid list with images // loaded from the web. -new ScrollGrid.count( +new GridView.count( crossAxisCount: 3, childAspectRatio: 1.0, padding: const EdgeInsets.all(4.0), diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index 3904f35bee0..475c358aa04 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart @@ -76,12 +76,12 @@ class AdaptiveContainer extends StatelessWidget { @override Widget build(BuildContext context) { if (MediaQuery.of(context).size.width < _kGridViewBreakpoint) { - return new ScrollView( + return new ListView( itemExtent: _kListItemExtent, children: names.map((String name) => new AdaptedListItem(name: name)).toList(), ); } else { - return new ScrollGrid.extent( + return new GridView.extent( maxCrossAxisExtent: _kMaxTileWidth, children: names.map((String name) => new AdaptedGridItem(name: name)).toList(), ); diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index e3fcdb5c3f6..105b5abccb9 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -121,7 +121,7 @@ class StockHomeState extends State { Widget _buildDrawer(BuildContext context) { return new Drawer( - child: new ScrollView( + child: new ListView( children: [ new DrawerHeader(child: new Center(child: new Text('Stocks'))), new DrawerItem( diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 1f1ba7ebf07..4c09c1ddc75 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -240,7 +240,7 @@ class StockSettingsState extends State { ]); return true; }); - return new ScrollView( + return new ListView( padding: const EdgeInsets.symmetric(vertical: 20.0), children: rows, ); diff --git a/packages/flutter/lib/src/material/grid_tile.dart b/packages/flutter/lib/src/material/grid_tile.dart index 06446f90b5a..c0e9bcdf189 100644 --- a/packages/flutter/lib/src/material/grid_tile.dart +++ b/packages/flutter/lib/src/material/grid_tile.dart @@ -8,13 +8,13 @@ import 'package:meta/meta.dart'; /// A tile in a material design grid list. /// -/// A grid list is a [ScrollGrid] of tiles in a vertical and horizontal +/// A grid list is a [GridView] 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: /// -/// * [ScrollGrid], which is a scrollable grid of tiles. +/// * [GridView], which is a scrollable grid of tiles. /// * [GridTileBar], which is typically used in either the [header] or /// [footer]. /// * diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index bf735479f2f..b8e9e7959f4 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -542,7 +542,7 @@ class _StepperState extends State with TickerProviderStateMixin { ); } - return new ScrollView( + return new ListView( shrinkWrap: true, children: children, ); diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index 618bd7e857c..f02e13a3645 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -283,7 +283,7 @@ class TwoLevelList extends StatelessWidget { @override Widget build(BuildContext context) { - return new ScrollView( + return new ListView( padding: padding, shrinkWrap: true, children: KeyedSubtree.ensureUniqueKeysForList(children), diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index ef00905a194..d0487a58f91 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -13,17 +13,13 @@ import 'scrollable.dart'; import 'sliver.dart'; import 'viewport.dart'; -/// A convenience widget that combines common scrolling-related widgets. -class ScrollView extends StatelessWidget { +abstract class ScrollView extends StatelessWidget { ScrollView({ Key key, this.scrollDirection: Axis.vertical, this.reverse: false, - this.padding, - this.itemExtent, this.physics, this.shrinkWrap: false, - this.children: const [], }) : super(key: key) { assert(reverse != null); assert(shrinkWrap != null); @@ -33,18 +29,10 @@ class ScrollView extends StatelessWidget { final bool reverse; - final EdgeInsets padding; - - final double itemExtent; - final ScrollPhysics physics; final bool shrinkWrap; - final List children; - - SliverChildListDelegate get childrenDelegate => new SliverChildListDelegate(children); - @protected AxisDirection getDirection(BuildContext context) { // TODO(abarth): Consider reading direction. @@ -58,6 +46,131 @@ class ScrollView extends StatelessWidget { } @protected + List buildSlivers(BuildContext context); + + @override + Widget build(BuildContext context) { + List slivers = buildSlivers(context); + AxisDirection axisDirection = getDirection(context); + return new Scrollable2( + axisDirection: axisDirection, + physics: physics, + viewportBuilder: (BuildContext context, ViewportOffset offset) { + if (shrinkWrap) { + return new ShrinkWrappingViewport( + axisDirection: axisDirection, + offset: offset, + slivers: slivers, + ); + } else { + return new Viewport2( + axisDirection: axisDirection, + offset: offset, + slivers: slivers, + ); + } + } + ); + } + + @override + void debugFillDescription(List description) { + super.debugFillDescription(description); + description.add('$scrollDirection'); + if (shrinkWrap) + description.add('shrink-wrapping'); + } +} + +abstract class BoxScrollView extends ScrollView { + BoxScrollView({ + Key key, + Axis scrollDirection: Axis.vertical, + bool reverse: false, + ScrollPhysics physics, + bool shrinkWrap: false, + this.padding, + }) : super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + ); + + final EdgeInsets padding; + + @override + List buildSlivers(BuildContext context) { + Widget sliver = buildChildLayout(context); + if (padding != null) + sliver = new SliverPadding(padding: padding, child: sliver); + return [ sliver ]; + } + + @protected + Widget buildChildLayout(BuildContext context); + + @override + void debugFillDescription(List description) { + super.debugFillDescription(description); + if (padding != null) + description.add('padding: $padding'); + } +} + +/// A scrollable list of boxes. +// TODO(ianh): More documentation here. +/// +/// See also: +/// +/// * [SingleChildScrollView], when you need to make a single child scrollable. +/// * [GridView], for a scrollable grid of boxes. +/// * [PageView], for a scrollable that works page by page. +class ListView extends BoxScrollView { + ListView({ + Key key, + Axis scrollDirection: Axis.vertical, + bool reverse: false, + ScrollPhysics physics, + bool shrinkWrap: false, + EdgeInsets padding, + this.itemExtent, + List children: const [], + }) : childrenDelegate = new SliverChildListDelegate(children), super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ); + + ListView.custom({ + Key key, + Axis scrollDirection: Axis.vertical, + bool reverse: false, + ScrollPhysics physics, + bool shrinkWrap: false, + EdgeInsets padding, + this.itemExtent, + @required this.childrenDelegate, + }) : super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ) { + assert(childrenDelegate != null); + } + + final double itemExtent; + + final SliverChildListDelegate childrenDelegate; + + @override Widget buildChildLayout(BuildContext context) { if (itemExtent != null) { return new SliverList( @@ -68,92 +181,122 @@ class ScrollView extends StatelessWidget { return new SliverBlock(delegate: childrenDelegate); } - @override - Widget build(BuildContext context) { - Widget sliver = buildChildLayout(context); - if (padding != null) - sliver = new SliverPadding(padding: padding, child: sliver); - AxisDirection axisDirection = getDirection(context); - return new Scrollable2( - axisDirection: axisDirection, - physics: physics, - viewportBuilder: (BuildContext context, ViewportOffset offset) { - if (shrinkWrap) { - return new ShrinkWrappingViewport( - axisDirection: axisDirection, - offset: offset, - slivers: [ sliver ], - ); - } else { - return new Viewport2( - axisDirection: axisDirection, - offset: offset, - slivers: [ sliver ], - ); - } - } - ); - } - @override void debugFillDescription(List description) { super.debugFillDescription(description); - description.add('$scrollDirection'); - if (padding != null) - description.add('padding: $padding'); if (itemExtent != null) description.add('itemExtent: $itemExtent'); - if (shrinkWrap) - description.add('shrink-wrapping'); } } -class ScrollGrid extends ScrollView { - ScrollGrid({ +/// A scrollable grid of boxes. +// TODO(ianh): More documentation here. +/// +/// See also: +/// +/// * [SingleChildScrollView], when you need to make a single child scrollable. +/// * [ListView], for a scrollable list of boxes. +/// * [PageView], for a scrollable that works page by page. +class GridView extends BoxScrollView { + GridView({ Key key, Axis scrollDirection: Axis.vertical, - EdgeInsets padding, + bool reverse: false, + ScrollPhysics physics, bool shrinkWrap: false, - this.gridDelegate, + EdgeInsets padding, + @required this.gridDelegate, List children: const [], - }) : super(key: key, scrollDirection: scrollDirection, padding: padding, shrinkWrap: shrinkWrap, children: children); + }) : childrenDelegate = new SliverChildListDelegate(children), super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ) { + assert(gridDelegate != null); + } - ScrollGrid.count({ + GridView.custom({ Key key, Axis scrollDirection: Axis.vertical, - EdgeInsets padding, + bool reverse: false, + ScrollPhysics physics, bool shrinkWrap: false, + EdgeInsets padding, + @required this.gridDelegate, + @required this.childrenDelegate, + }) : super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ) { + assert(gridDelegate != null); + assert(childrenDelegate != null); + } + + GridView.count({ + Key key, + Axis scrollDirection: Axis.vertical, + bool reverse: false, + ScrollPhysics physics, + bool shrinkWrap: false, + EdgeInsets padding, @required int crossAxisCount, double mainAxisSpacing: 0.0, double crossAxisSpacing: 0.0, double childAspectRatio: 1.0, List children: const [], }) : gridDelegate = new SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: crossAxisCount, - mainAxisSpacing: mainAxisSpacing, - crossAxisSpacing: crossAxisSpacing, - childAspectRatio: childAspectRatio, - ), super(key: key, scrollDirection: scrollDirection, padding: padding, shrinkWrap: shrinkWrap, children: children); + crossAxisCount: crossAxisCount, + mainAxisSpacing: mainAxisSpacing, + crossAxisSpacing: crossAxisSpacing, + childAspectRatio: childAspectRatio, + ), + childrenDelegate = new SliverChildListDelegate(children), super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ); - ScrollGrid.extent({ + GridView.extent({ Key key, Axis scrollDirection: Axis.vertical, - EdgeInsets padding, + bool reverse: false, + ScrollPhysics physics, bool shrinkWrap: false, + EdgeInsets padding, @required double maxCrossAxisExtent, double mainAxisSpacing: 0.0, double crossAxisSpacing: 0.0, double childAspectRatio: 1.0, List children: const [], }) : gridDelegate = new SliverGridDelegateWithMaxCrossAxisExtent( - maxCrossAxisExtent: maxCrossAxisExtent, - mainAxisSpacing: mainAxisSpacing, - crossAxisSpacing: crossAxisSpacing, - childAspectRatio: childAspectRatio, - ), super(key: key, scrollDirection: scrollDirection, padding: padding, shrinkWrap: shrinkWrap, children: children); + maxCrossAxisExtent: maxCrossAxisExtent, + mainAxisSpacing: mainAxisSpacing, + crossAxisSpacing: crossAxisSpacing, + childAspectRatio: childAspectRatio, + ), + childrenDelegate = new SliverChildListDelegate(children), super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ); final SliverGridDelegate gridDelegate; + final SliverChildListDelegate childrenDelegate; + @override Widget buildChildLayout(BuildContext context) { return new SliverGrid( @@ -163,17 +306,52 @@ class ScrollGrid extends ScrollView { } } -class PageView extends ScrollView { +/// A scrollable list that works page by page. +// TODO(ianh): More documentation here. +/// +/// See also: +/// +/// * [SingleChildScrollView], when you need to make a single child scrollable. +/// * [ListView], for a scrollable list of boxes. +/// * [GridView], for a scrollable grid of boxes. +class PageView extends BoxScrollView { PageView({ Key key, Axis scrollDirection: Axis.horizontal, + bool reverse: false, + ScrollPhysics physics: const PageScrollPhysics(), + bool shrinkWrap: false, + EdgeInsets padding, List children: const [], + }) : childrenDelegate = new SliverChildListDelegate(children), super( + key: key, + scrollDirection: scrollDirection, + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ); + + PageView.custom({ + Key key, + Axis scrollDirection: Axis.horizontal, + bool reverse: false, + ScrollPhysics physics: const PageScrollPhysics(), + bool shrinkWrap: false, + EdgeInsets padding, + @required this.childrenDelegate, }) : super( key: key, scrollDirection: scrollDirection, - physics: const PageScrollPhysics(), - children: children, - ); + reverse: reverse, + physics: physics, + shrinkWrap: shrinkWrap, + padding: padding, + ) { + assert(childrenDelegate != null); + } + + final SliverChildListDelegate childrenDelegate; @override Widget buildChildLayout(BuildContext context) { diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index f8bc058da6a..35498577dcf 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -10,13 +10,31 @@ import 'basic.dart'; import 'framework.dart'; import 'scrollable.dart'; -// /// -// /// The viewport will shrink-wrap the child in both axes. -// /// -// /// See also: -// /// * [ScrollView], which handles multiple children in a scrolling list. -// /// * [ScrollGrid], which handles multiple children in a scrolling grid. -// /// * [Scrollable2], which handles arbitrary scrolling effects. + +/// A box in which a single widget can be scrolled. +/// +/// This widget is useful when you have a single box that will normally be +/// entirely visible, for example a clock face in a time picker, but you need to +/// make sure it can be scrolled if the container gets too small in one axis +/// (the scroll direction). +/// +/// It is also useful if you need to shrink-wrap in both axes (the main +/// scrolling direction as well as the cross axis), as one might see in a dialog +/// or pop-up menu. In that case, you might pair the [SingleChildScrollView] +/// with a [BlockBody] child. +/// +/// When you have a list of children and do not require cross-axis +/// shrink-wrapping behavior, for example a scrolling list that is always the +/// width of the screen, consider [ListView], which is vastly more efficient +/// that a [SingleChildScrollView] containing a [BlockBody] or [Column] with +/// many children. +/// +/// See also: +/// +/// * [ListView], which handles multiple children in a scrolling list. +/// * [GridView], which handles multiple children in a scrolling grid. +/// * [PageView], for a scrollable that works page by page. +/// * [Scrollable2], which handles arbitrary scrolling effects. class SingleChildScrollView extends StatelessWidget { SingleChildScrollView({ Key key, diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index 6775ec29101..c5722e21b8c 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -18,7 +18,7 @@ void main() { title: new Text('Home'), ), drawer: new Drawer( - child: new ScrollView( + child: new ListView( children: [ new AboutDrawerItem( applicationVersion: '0.1.2', diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart index 98e8925eb67..25d86ce986e 100644 --- a/packages/flutter/test/material/drawer_test.dart +++ b/packages/flutter/test/material/drawer_test.dart @@ -12,7 +12,7 @@ void main() { await tester.pumpWidget( new Scaffold( drawer: new Drawer( - child: new ScrollView( + child: new ListView( children: [ new DrawerHeader( child: new Container( diff --git a/packages/flutter/test/material/list_item_test.dart b/packages/flutter/test/material/list_item_test.dart index d97bc74e53c..02635b97175 100644 --- a/packages/flutter/test/material/list_item_test.dart +++ b/packages/flutter/test/material/list_item_test.dart @@ -32,7 +32,7 @@ void main() { home: new Material( child: new Builder( builder: (BuildContext context) { - return new ScrollView( + return new ListView( children: ListItem.divideItems( context: context, items: titles.map((String title) => new ListItem(title: new Text(title))), diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index db8c6f89aa5..28216839a03 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -50,9 +50,9 @@ void main() { }); testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async { - await tester.pumpWidget(new ScrollView(children: [new LinearProgressIndicator(value: 0.0)])); + await tester.pumpWidget(new ListView(children: [new LinearProgressIndicator(value: 0.0)])); List layers1 = tester.layers; - await tester.pumpWidget(new ScrollView(children: [new LinearProgressIndicator(value: 0.5)])); + await tester.pumpWidget(new ListView(children: [new LinearProgressIndicator(value: 0.5)])); List layers2 = tester.layers; expect(layers1, isNot(equals(layers2))); }); diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index 7617f04c741..a9824964e93 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -17,7 +17,7 @@ void main() { height: 200.0, width: 300.0, child: new Scrollbar2( - child: new ScrollView( + child: new ListView( children: [ new Container(height: 40.0, child: new Text('0')), new Container(height: 40.0, child: new Text('1')), @@ -35,13 +35,13 @@ void main() { ); SchedulerBinding.instance.debugAssertNoTransientCallbacks('Building a list with a scrollbar triggered an animation.'); - await tester.tap(find.byType(ScrollView)); + await tester.tap(find.byType(ListView)); SchedulerBinding.instance.debugAssertNoTransientCallbacks('Tapping a block with a scrollbar triggered an animation.'); await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200)); - await tester.scroll(find.byType(ScrollView), const Offset(0.0, -10.0)); + await tester.scroll(find.byType(ListView), const Offset(0.0, -10.0)); expect(SchedulerBinding.instance.transientCallbackCount, greaterThan(0)); await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200)); diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index c5e4ffc0405..89c88a61608 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -115,7 +115,7 @@ void main() { (WidgetTester tester) async { double value = 0.0; await tester.pumpWidget(new Material( - child: new ScrollView( + child: new ListView( children: [ new Slider( value: value, diff --git a/packages/flutter/test/widgets/block_test.dart b/packages/flutter/test/widgets/block_test.dart index 89e6f354869..04d574eff67 100644 --- a/packages/flutter/test/widgets/block_test.dart +++ b/packages/flutter/test/widgets/block_test.dart @@ -13,7 +13,7 @@ final Key blockKey = new Key('test'); void main() { testWidgets('Cannot scroll a non-overflowing block', (WidgetTester tester) async { await tester.pumpWidget( - new ScrollView( + new ListView( key: blockKey, children: [ new Container( @@ -38,7 +38,7 @@ void main() { testWidgets('Can scroll an overflowing block', (WidgetTester tester) async { await tester.pumpWidget( - new ScrollView( + new ListView( key: blockKey, children: [ new Container( diff --git a/packages/flutter/test/widgets/center_test.dart b/packages/flutter/test/widgets/center_test.dart index 374856758e3..7cdac37f62f 100644 --- a/packages/flutter/test/widgets/center_test.dart +++ b/packages/flutter/test/widgets/center_test.dart @@ -7,6 +7,6 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Can be placed in an infinite box', (WidgetTester tester) async { - await tester.pumpWidget(new ScrollView(children: [new Center()])); + await tester.pumpWidget(new ListView(children: [new Center()])); }); } diff --git a/packages/flutter/test/widgets/container_test.dart b/packages/flutter/test/widgets/container_test.dart index 3f195e685ff..82ee85f41fe 100644 --- a/packages/flutter/test/widgets/container_test.dart +++ b/packages/flutter/test/widgets/container_test.dart @@ -50,6 +50,6 @@ void main() { }); testWidgets('Can be placed in an infinite box', (WidgetTester tester) async { - await tester.pumpWidget(new ScrollView(children: [new Container()])); + await tester.pumpWidget(new ListView(children: [new Container()])); }); } diff --git a/packages/flutter/test/widgets/date_picker_test.dart b/packages/flutter/test/widgets/date_picker_test.dart index 1ee34e62eb4..95e4a71725c 100644 --- a/packages/flutter/test/widgets/date_picker_test.dart +++ b/packages/flutter/test/widgets/date_picker_test.dart @@ -10,7 +10,7 @@ void main() { DateTime currentValue; Widget widget = new Material( - child: new ScrollView( + child: new ListView( children: [ new MonthPicker( selectedDate: new DateTime.utc(2015, 6, 9, 7, 12), diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index 927bb7452ea..c69624891ad 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -312,7 +312,7 @@ void main() { Point firstLocation, secondLocation, thirdLocation; await tester.pumpWidget(new MaterialApp( - home: new ScrollView( + home: new ListView( children: [ new DragTarget( builder: (BuildContext context, List data, List rejects) { @@ -418,7 +418,7 @@ void main() { Point firstLocation, secondLocation, thirdLocation; await tester.pumpWidget(new MaterialApp( - home: new ScrollView( + home: new ListView( scrollDirection: Axis.horizontal, children: [ new DragTarget( diff --git a/packages/flutter/test/widgets/drawer_test.dart b/packages/flutter/test/widgets/drawer_test.dart index eb59d424fa9..d468f758d4b 100644 --- a/packages/flutter/test/widgets/drawer_test.dart +++ b/packages/flutter/test/widgets/drawer_test.dart @@ -135,7 +135,7 @@ void main() { return new Scaffold( key: scaffoldKey, drawer: new Drawer( - child: new ScrollView( + child: new ListView( children: [ new Text('drawer'), new FlatButton( diff --git a/packages/flutter/test/widgets/form_test.dart b/packages/flutter/test/widgets/form_test.dart index 65fb2ff7cf5..f942a2751e7 100644 --- a/packages/flutter/test/widgets/form_test.dart +++ b/packages/flutter/test/widgets/form_test.dart @@ -149,7 +149,7 @@ void main() { autovalidate: true, child: new Focus( key: focusKey, - child: new ScrollView( + child: new ListView( children: [ new TextField( key: fieldKey diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 1c7637732d8..39da0924558 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -11,7 +11,7 @@ Key thirdKey = new Key('third'); final Map routes = { '/': (BuildContext context) => new Material( - child: new ScrollView( + child: new ListView( children: [ 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))), @@ -21,7 +21,7 @@ final Map routes = { ) ), '/two': (BuildContext context) => new Material( - child: new ScrollView( + child: new ListView( children: [ 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))), @@ -35,7 +35,7 @@ final Map routes = { class ThreeRoute extends MaterialPageRoute { ThreeRoute() : super(builder: (BuildContext context) { return new Material( - child: new ScrollView( + child: new ListView( children: [ 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))), @@ -168,7 +168,7 @@ void main() { await tester.pumpWidget(new MaterialApp( home: new Material( - child: new ScrollView( + child: new ListView( children: [ new Hero(tag: 'a', child: new Text('foo')), new Builder(builder: (BuildContext context) { diff --git a/packages/flutter/test/widgets/list_test.dart b/packages/flutter/test/widgets/list_test.dart index 2072950c9b6..d5d6247b4d4 100644 --- a/packages/flutter/test/widgets/list_test.dart +++ b/packages/flutter/test/widgets/list_test.dart @@ -6,9 +6,9 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; void main() { - testWidgets('ScrollView itemExtent control test', (WidgetTester tester) async { + testWidgets('ListView itemExtent control test', (WidgetTester tester) async { await tester.pumpWidget( - new ScrollView( + new ListView( itemExtent: 200.0, children: new List.generate(20, (int i) { return new Container( @@ -27,7 +27,7 @@ void main() { expect(find.text('3'), findsNothing); expect(find.text('4'), findsNothing); - await tester.scroll(find.byType(ScrollView), const Offset(0.0, -250.0)); + await tester.scroll(find.byType(ListView), const Offset(0.0, -250.0)); await tester.pump(); expect(find.text('0'), findsNothing); @@ -38,7 +38,7 @@ void main() { expect(find.text('5'), findsNothing); expect(find.text('6'), findsNothing); - await tester.scroll(find.byType(ScrollView), const Offset(0.0, 200.0)); + await tester.scroll(find.byType(ListView), const Offset(0.0, 200.0)); await tester.pump(); expect(find.text('0'), findsOneWidget); @@ -49,11 +49,11 @@ void main() { expect(find.text('5'), findsNothing); }); - testWidgets('ScrollView large scroll jump', (WidgetTester tester) async { + testWidgets('ListView large scroll jump', (WidgetTester tester) async { List log = []; await tester.pumpWidget( - new ScrollView( + new ListView( itemExtent: 200.0, children: new List.generate(20, (int i) { return new Builder( diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 096ba5e4e56..ec1572c0769 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -195,7 +195,7 @@ void main() { StateMarkerState keyState = key.currentState; keyState.marker = "marked"; - await tester.pumpWidget(new ScrollView( + await tester.pumpWidget(new ListView( itemExtent: 100.0, children: [ new Container( diff --git a/packages/flutter/test/widgets/scroll_grid_test.dart b/packages/flutter/test/widgets/scroll_grid_test.dart index 6501fb8fd9b..5e4d35ce033 100644 --- a/packages/flutter/test/widgets/scroll_grid_test.dart +++ b/packages/flutter/test/widgets/scroll_grid_test.dart @@ -8,17 +8,17 @@ import 'package:flutter/widgets.dart'; import 'states.dart'; void main() { - testWidgets('Empty ScrollGrid', (WidgetTester tester) async { - await tester.pumpWidget(new ScrollGrid.count( + testWidgets('Empty GridView', (WidgetTester tester) async { + await tester.pumpWidget(new GridView.count( crossAxisCount: 4, children: const [], )); }); - testWidgets('ScrollGrid.count control test', (WidgetTester tester) async { + testWidgets('GridView.count control test', (WidgetTester tester) async { List log = []; - await tester.pumpWidget(new ScrollGrid.count( + await tester.pumpWidget(new GridView.count( crossAxisCount: 4, children: kStates.map((String state) { return new GestureDetector( @@ -83,10 +83,10 @@ void main() { log.clear(); }); - testWidgets('ScrollGrid.extent control test', (WidgetTester tester) async { + testWidgets('GridView.extent control test', (WidgetTester tester) async { List log = []; - await tester.pumpWidget(new ScrollGrid.extent( + await tester.pumpWidget(new GridView.extent( maxCrossAxisExtent: 200.0, children: kStates.map((String state) { return new GestureDetector( @@ -126,11 +126,11 @@ void main() { log.clear(); }); - testWidgets('ScrollGrid large scroll jump', (WidgetTester tester) async { + testWidgets('GridView large scroll jump', (WidgetTester tester) async { List log = []; await tester.pumpWidget( - new ScrollGrid.extent( + new GridView.extent( scrollDirection: Axis.horizontal, maxCrossAxisExtent: 200.0, childAspectRatio: 0.75, @@ -186,11 +186,11 @@ void main() { log.clear(); }); - testWidgets('ScrollGrid - change crossAxisCount', (WidgetTester tester) async { + testWidgets('GridView - change crossAxisCount', (WidgetTester tester) async { List log = []; await tester.pumpWidget( - new ScrollGrid( + new GridView( gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, ), @@ -217,7 +217,7 @@ void main() { log.clear(); await tester.pumpWidget( - new ScrollGrid( + new GridView( gridDelegate: new SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), @@ -245,11 +245,11 @@ void main() { expect(find.text('4'), findsNothing); }); - testWidgets('ScrollGrid - change maxChildCrossAxisExtent', (WidgetTester tester) async { + testWidgets('GridView - change maxChildCrossAxisExtent', (WidgetTester tester) async { List log = []; await tester.pumpWidget( - new ScrollGrid( + new GridView( gridDelegate: new SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200.0, ), @@ -276,7 +276,7 @@ void main() { log.clear(); await tester.pumpWidget( - new ScrollGrid( + new GridView( gridDelegate: new SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 400.0, ), diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index 93d896a85e6..cfc9deab9a6 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart'; import 'states.dart'; void main() { - testWidgets('ScrollView control test', (WidgetTester tester) async { + testWidgets('ListView control test', (WidgetTester tester) async { List log = []; - await tester.pumpWidget(new ScrollView( + await tester.pumpWidget(new ListView( children: kStates.map((String state) { return new GestureDetector( onTap: () { @@ -45,9 +45,9 @@ void main() { log.clear(); }); - testWidgets('ScrollView restart ballistic activity out of range', (WidgetTester tester) async { - Widget buildScrollView(int n) { - return new ScrollView( + testWidgets('ListView restart ballistic activity out of range', (WidgetTester tester) async { + Widget buildListView(int n) { + return new ListView( children: kStates.take(n).map((String state) { return new Container( height: 200.0, @@ -60,9 +60,9 @@ void main() { ); } - await tester.pumpWidget(buildScrollView(30)); - await tester.fling(find.byType(ScrollView), const Offset(0.0, -4000.0), 4000.0); - await tester.pumpWidget(buildScrollView(15)); + await tester.pumpWidget(buildListView(30)); + await tester.fling(find.byType(ListView), const Offset(0.0, -4000.0), 4000.0); + await tester.pumpWidget(buildListView(15)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); diff --git a/packages/flutter/test/widgets/scrollable_dispose_test.dart b/packages/flutter/test/widgets/scrollable_dispose_test.dart index 24aa9225efb..cd1d17b56bc 100644 --- a/packages/flutter/test/widgets/scrollable_dispose_test.dart +++ b/packages/flutter/test/widgets/scrollable_dispose_test.dart @@ -13,11 +13,11 @@ void main() { for (int i = 0; i < 250; i++) textWidgets.add(new Text('$i')); await tester.pumpWidget(new FlipWidget( - left: new ScrollView(children: textWidgets), + left: new ListView(children: textWidgets), right: new Container() )); - await tester.fling(find.byType(ScrollView), const Offset(0.0, -200.0), 1000.0); + await tester.fling(find.byType(ListView), const Offset(0.0, -200.0), 1000.0); await tester.pump(); tester.state(find.byType(FlipWidget)).flip(); diff --git a/packages/flutter/test/widgets/scrollable_grid_test.dart b/packages/flutter/test/widgets/scrollable_grid_test.dart index c44d204ad64..35b89e7d6ea 100644 --- a/packages/flutter/test/widgets/scrollable_grid_test.dart +++ b/packages/flutter/test/widgets/scrollable_grid_test.dart @@ -7,23 +7,23 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/rendering.dart'; void main() { - testWidgets('ScrollGrid default control', (WidgetTester tester) async { + testWidgets('GridView default control', (WidgetTester tester) async { await tester.pumpWidget(new Center( - child: new ScrollGrid.count( + child: new GridView.count( crossAxisCount: 1, ), )); }); // Tests https://github.com/flutter/flutter/issues/5522 - testWidgets('ScrollGrid displays correct children with nonzero padding', (WidgetTester tester) async { + testWidgets('GridView 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 ScrollGrid.count( + child: new GridView.count( crossAxisCount: 1, padding: padding, children: new List.generate(10, (int index) { diff --git a/packages/flutter/test/widgets/semantics_debugger_test.dart b/packages/flutter/test/widgets/semantics_debugger_test.dart index ce8be6f920e..676c4cdf9d0 100644 --- a/packages/flutter/test/widgets/semantics_debugger_test.dart +++ b/packages/flutter/test/widgets/semantics_debugger_test.dart @@ -126,7 +126,7 @@ void main() { await tester.pumpWidget( new SemanticsDebugger( child: new Material( - child: new ScrollView( + child: new ListView( children: [ new RaisedButton( onPressed: () { @@ -160,7 +160,7 @@ void main() { await tester.pumpWidget( new SemanticsDebugger( - child: new ScrollView( + child: new ListView( children: [ new Container( key: childKey, @@ -175,22 +175,22 @@ void main() { expect(tester.getTopLeft(find.byKey(childKey)).y, equals(0.0)); - await tester.fling(find.byType(ScrollView), const Offset(0.0, -200.0), 200.0); + await tester.fling(find.byType(ListView), const Offset(0.0, -200.0), 200.0); await tester.pump(); expect(tester.getTopLeft(find.byKey(childKey)).y, equals(-480.0)); - await tester.fling(find.byType(ScrollView), const Offset(200.0, 0.0), 200.0); + await tester.fling(find.byType(ListView), const Offset(200.0, 0.0), 200.0); await tester.pump(); expect(tester.getTopLeft(find.byKey(childKey)).y, equals(-480.0)); - await tester.fling(find.byType(ScrollView), const Offset(-200.0, 0.0), 200.0); + await tester.fling(find.byType(ListView), const Offset(-200.0, 0.0), 200.0); await tester.pump(); expect(tester.getTopLeft(find.byKey(childKey)).y, equals(-480.0)); - await tester.fling(find.byType(ScrollView), const Offset(0.0, 200.0), 200.0); + await tester.fling(find.byType(ListView), const Offset(0.0, 200.0), 200.0); await tester.pump(); expect(tester.getTopLeft(find.byKey(childKey)).y, equals(0.0)); @@ -247,7 +247,7 @@ void main() { await tester.pumpWidget( new SemanticsDebugger( child: new Material( - child: new ScrollView( + child: new ListView( children: [ new Checkbox( key: keyTop,