Commit 332a2303 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Rename and refactor ScrollView hierarchy (#7865)

This prepares us for a CustomScrollView that takes slivers.
parent 7fea0593
......@@ -588,7 +588,7 @@ class GalleryDrawer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new FancyDrawerHeader(),
new DrawerItem(
......
......@@ -123,7 +123,7 @@ class CardCollectionState extends State<CardCollection> {
return new Drawer(
child: new IconTheme(
data: const IconThemeData(color: Colors.black),
child: new ScrollView(
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Options'))),
buildDrawerCheckbox("Make card labels editable", _editable, _toggleEditable),
......
......@@ -84,7 +84,7 @@ class PageableListAppState extends State<PageableListApp> {
Widget _buildDrawer() {
return new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Options'))),
new DrawerItem(
......
......@@ -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) {
......
......@@ -41,7 +41,7 @@ class _ChipDemoState extends State<ChipDemo> {
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,
......
......@@ -98,7 +98,7 @@ class ColorSwatchTabView extends StatelessWidget {
}).toList());
}
return new ScrollView(
return new ListView(
itemExtent: kColorItemHeight,
children: colorItems,
);
......
......@@ -165,7 +165,7 @@ class _DataTableDemoState extends State<DataTableDemo> {
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: <Widget>[
new PaginatedDataTable(
......
......@@ -89,7 +89,7 @@ class DialogDemoState extends State<DialogDemo> {
appBar: new AppBar(
title: new Text('Dialogs')
),
body: new ScrollView(
body: new ListView(
padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0),
children: <Widget>[
new RaisedButton(
......
......@@ -88,7 +88,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
title: new Text('Navigation drawer'),
),
drawer: new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new UserAccountsDrawerHeader(
accountName: new Text('Zach Widget'),
......
......@@ -157,7 +157,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
)
]
),
body: new ScrollView(
body: new ListView(
padding: const EdgeInsets.all(16.0),
children: <Widget>[
new Container(
......
......@@ -339,7 +339,7 @@ class GridListDemoState extends State<GridListDemo> {
body: new Column(
children: <Widget>[
new Expanded(
child: new ScrollGrid.count(
child: new GridView.count(
crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3,
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
......
......@@ -161,7 +161,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
)
]
),
body: new ScrollView(
body: new ListView(
children: leaveBehindItems.map(buildItem).toList()
)
);
......
......@@ -40,7 +40,7 @@ class ListDemoState extends State<ListDemo> {
decoration: new BoxDecoration(
border: new Border(top: new BorderSide(color: Colors.black26))
),
child: new ScrollView(
child: new ListView(
shrinkWrap: true,
children: <Widget>[
new ListItem(
......
......@@ -83,7 +83,7 @@ class MenuDemoState extends State<MenuDemo> {
)
]
),
body: new ScrollView(
body: new ListView(
padding: const EdgeInsets.symmetric(vertical: 8.0),
children: <Widget>[
// Pressing the PopupMenuButton on the right of this item shows
......
......@@ -29,7 +29,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
int _snackBarIndex = 1;
Widget buildBody(BuildContext context) {
return new ScrollView(
return new ListView(
padding: const EdgeInsets.all(24.0),
children: <Widget>[
new Text(_text1),
......
......@@ -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) {
......
......@@ -22,7 +22,7 @@ class TooltipDemo extends StatelessWidget {
),
body: new Builder(
builder: (BuildContext context) {
return new ScrollView(
return new ListView(
children: <Widget>[
new Text(_introText, style: theme.textTheme.subhead),
new Row(
......
......@@ -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)
);
}
}
......@@ -305,6 +305,6 @@ class GalleryDrawer extends StatelessWidget {
));
}
return new Drawer(child: new ScrollView(children: allDrawerItems));
return new Drawer(child: new ListView(children: allDrawerItems));
}
}
......@@ -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),
......
......@@ -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(),
);
......
......@@ -121,7 +121,7 @@ class StockHomeState extends State<StockHome> {
Widget _buildDrawer(BuildContext context) {
return new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new DrawerHeader(child: new Center(child: new Text('Stocks'))),
new DrawerItem(
......
......@@ -240,7 +240,7 @@ class StockSettingsState extends State<StockSettings> {
]);
return true;
});
return new ScrollView(
return new ListView(
padding: const EdgeInsets.symmetric(vertical: 20.0),
children: rows,
);
......
......@@ -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].
/// * <https://material.google.com/components/grid-lists.html>
......
......@@ -542,7 +542,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
);
}
return new ScrollView(
return new ListView(
shrinkWrap: true,
children: children,
);
......
......@@ -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),
......
......@@ -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 <Widget>[],
}) : 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<Widget> children;
SliverChildListDelegate get childrenDelegate => new SliverChildListDelegate(children);
@protected
AxisDirection getDirection(BuildContext context) {
// TODO(abarth): Consider reading direction.
......@@ -58,21 +46,11 @@ class ScrollView extends StatelessWidget {
}
@protected
Widget buildChildLayout(BuildContext context) {
if (itemExtent != null) {
return new SliverList(
delegate: childrenDelegate,
itemExtent: itemExtent,
);
}
return new SliverBlock(delegate: childrenDelegate);
}
List<Widget> buildSlivers(BuildContext context);
@override
Widget build(BuildContext context) {
Widget sliver = buildChildLayout(context);
if (padding != null)
sliver = new SliverPadding(padding: padding, child: sliver);
List<Widget> slivers = buildSlivers(context);
AxisDirection axisDirection = getDirection(context);
return new Scrollable2(
axisDirection: axisDirection,
......@@ -82,13 +60,13 @@ class ScrollView extends StatelessWidget {
return new ShrinkWrappingViewport(
axisDirection: axisDirection,
offset: offset,
slivers: <Widget>[ sliver ],
slivers: slivers,
);
} else {
return new Viewport2(
axisDirection: axisDirection,
offset: offset,
slivers: <Widget>[ sliver ],
slivers: slivers,
);
}
}
......@@ -99,30 +77,175 @@ class ScrollView extends StatelessWidget {
void debugFillDescription(List<String> 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<Widget> buildSlivers(BuildContext context) {
Widget sliver = buildChildLayout(context);
if (padding != null)
sliver = new SliverPadding(padding: padding, child: sliver);
return <Widget>[ sliver ];
}
@protected
Widget buildChildLayout(BuildContext context);
@override
void debugFillDescription(List<String> 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<Widget> children: const <Widget>[],
}) : 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(
delegate: childrenDelegate,
itemExtent: itemExtent,
);
}
return new SliverBlock(delegate: childrenDelegate);
}
@override
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
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<Widget> children: const <Widget>[],
}) : 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,
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,
......@@ -133,13 +256,23 @@ class ScrollGrid extends ScrollView {
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio,
), 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,
);
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,
......@@ -150,10 +283,20 @@ class ScrollGrid extends ScrollView {
mainAxisSpacing: mainAxisSpacing,
crossAxisSpacing: crossAxisSpacing,
childAspectRatio: childAspectRatio,
), 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,
);
final SliverGridDelegate gridDelegate;
final SliverChildListDelegate childrenDelegate;
@override
Widget buildChildLayout(BuildContext context) {
return new SliverGrid(
......@@ -163,18 +306,53 @@ 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<Widget> children: const <Widget>[],
}) : super(
}) : childrenDelegate = new SliverChildListDelegate(children), super(
key: key,
scrollDirection: scrollDirection,
physics: const PageScrollPhysics(),
children: children,
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,
reverse: reverse,
physics: physics,
shrinkWrap: shrinkWrap,
padding: padding,
) {
assert(childrenDelegate != null);
}
final SliverChildListDelegate childrenDelegate;
@override
Widget buildChildLayout(BuildContext context) {
return new SliverFill(delegate: childrenDelegate);
......
......@@ -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,
......
......@@ -18,7 +18,7 @@ void main() {
title: new Text('Home'),
),
drawer: new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new AboutDrawerItem(
applicationVersion: '0.1.2',
......
......@@ -12,7 +12,7 @@ void main() {
await tester.pumpWidget(
new Scaffold(
drawer: new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new DrawerHeader(
child: new Container(
......
......@@ -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))),
......
......@@ -50,9 +50,9 @@ void main() {
});
testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async {
await tester.pumpWidget(new ScrollView(children: <Widget>[new LinearProgressIndicator(value: 0.0)]));
await tester.pumpWidget(new ListView(children: <Widget>[new LinearProgressIndicator(value: 0.0)]));
List<Layer> layers1 = tester.layers;
await tester.pumpWidget(new ScrollView(children: <Widget>[new LinearProgressIndicator(value: 0.5)]));
await tester.pumpWidget(new ListView(children: <Widget>[new LinearProgressIndicator(value: 0.5)]));
List<Layer> layers2 = tester.layers;
expect(layers1, isNot(equals(layers2)));
});
......
......@@ -17,7 +17,7 @@ void main() {
height: 200.0,
width: 300.0,
child: new Scrollbar2(
child: new ScrollView(
child: new ListView(
children: <Widget>[
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));
......
......@@ -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: <Widget>[
new Slider(
value: value,
......
......@@ -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: <Widget>[
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: <Widget>[
new Container(
......
......@@ -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: <Widget>[new Center()]));
await tester.pumpWidget(new ListView(children: <Widget>[new Center()]));
});
}
......@@ -50,6 +50,6 @@ void main() {
});
testWidgets('Can be placed in an infinite box', (WidgetTester tester) async {
await tester.pumpWidget(new ScrollView(children: <Widget>[new Container()]));
await tester.pumpWidget(new ListView(children: <Widget>[new Container()]));
});
}
......@@ -10,7 +10,7 @@ void main() {
DateTime currentValue;
Widget widget = new Material(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new MonthPicker(
selectedDate: new DateTime.utc(2015, 6, 9, 7, 12),
......
......@@ -312,7 +312,7 @@ void main() {
Point firstLocation, secondLocation, thirdLocation;
await tester.pumpWidget(new MaterialApp(
home: new ScrollView(
home: new ListView(
children: <Widget>[
new DragTarget<int>(
builder: (BuildContext context, List<int> data, List<dynamic> 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: <Widget>[
new DragTarget<int>(
......
......@@ -135,7 +135,7 @@ void main() {
return new Scaffold(
key: scaffoldKey,
drawer: new Drawer(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new Text('drawer'),
new FlatButton(
......
......@@ -149,7 +149,7 @@ void main() {
autovalidate: true,
child: new Focus(
key: focusKey,
child: new ScrollView(
child: new ListView(
children: <Widget>[
new TextField(
key: fieldKey
......
......@@ -11,7 +11,7 @@ Key thirdKey = new Key('third');
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => new Material(
child: new ScrollView(
child: new ListView(
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))),
......@@ -21,7 +21,7 @@ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
)
),
'/two': (BuildContext context) => new Material(
child: new ScrollView(
child: new ListView(
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))),
......@@ -35,7 +35,7 @@ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
class ThreeRoute extends MaterialPageRoute<Null> {
ThreeRoute() : super(builder: (BuildContext context) {
return new Material(
child: new ScrollView(
child: new ListView(
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))),
......@@ -168,7 +168,7 @@ void main() {
await tester.pumpWidget(new MaterialApp(
home: new Material(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new Hero(tag: 'a', child: new Text('foo')),
new Builder(builder: (BuildContext context) {
......
......@@ -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<Widget>.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<int> log = <int>[];
await tester.pumpWidget(
new ScrollView(
new ListView(
itemExtent: 200.0,
children: new List<Widget>.generate(20, (int i) {
return new Builder(
......
......@@ -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: <Widget>[
new Container(
......
......@@ -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 <Widget>[],
));
});
testWidgets('ScrollGrid.count control test', (WidgetTester tester) async {
testWidgets('GridView.count control test', (WidgetTester tester) async {
List<String> log = <String>[];
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<String> log = <String>[];
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<int> log = <int>[];
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<int> log = <int>[];
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<int> log = <int>[];
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,
),
......
......@@ -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<String> log = <String>[];
await tester.pumpWidget(new ScrollView(
await tester.pumpWidget(new ListView(
children: kStates.map<Widget>((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<Widget>((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));
......
......@@ -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<FlipWidgetState>(find.byType(FlipWidget)).flip();
......
......@@ -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<Widget>.generate(10, (int index) {
......
......@@ -126,7 +126,7 @@ void main() {
await tester.pumpWidget(
new SemanticsDebugger(
child: new Material(
child: new ScrollView(
child: new ListView(
children: <Widget>[
new RaisedButton(
onPressed: () {
......@@ -160,7 +160,7 @@ void main() {
await tester.pumpWidget(
new SemanticsDebugger(
child: new ScrollView(
child: new ListView(
children: <Widget>[
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: <Widget>[
new Checkbox(
key: keyTop,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment