Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
332a2303
Commit
332a2303
authored
Feb 04, 2017
by
Ian Hickson
Committed by
GitHub
Feb 04, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename and refactor ScrollView hierarchy (#7865)
This prepares us for a CustomScrollView that takes slivers.
parent
7fea0593
Changes
49
Show whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
346 additions
and
150 deletions
+346
-150
main.dart
dev/benchmarks/complex_layout/lib/main.dart
+1
-1
card_collection.dart
dev/manual_tests/card_collection.dart
+1
-1
pageable_list.dart
dev/manual_tests/pageable_list.dart
+1
-1
cards_demo.dart
examples/flutter_gallery/lib/demo/cards_demo.dart
+1
-1
chip_demo.dart
examples/flutter_gallery/lib/demo/chip_demo.dart
+1
-1
colors_demo.dart
examples/flutter_gallery/lib/demo/colors_demo.dart
+1
-1
data_table_demo.dart
examples/flutter_gallery/lib/demo/data_table_demo.dart
+1
-1
dialog_demo.dart
examples/flutter_gallery/lib/demo/dialog_demo.dart
+1
-1
drawer_demo.dart
examples/flutter_gallery/lib/demo/drawer_demo.dart
+1
-1
full_screen_dialog_demo.dart
...les/flutter_gallery/lib/demo/full_screen_dialog_demo.dart
+1
-1
grid_list_demo.dart
examples/flutter_gallery/lib/demo/grid_list_demo.dart
+1
-1
leave_behind_demo.dart
examples/flutter_gallery/lib/demo/leave_behind_demo.dart
+1
-1
list_demo.dart
examples/flutter_gallery/lib/demo/list_demo.dart
+1
-1
menu_demo.dart
examples/flutter_gallery/lib/demo/menu_demo.dart
+1
-1
snack_bar_demo.dart
examples/flutter_gallery/lib/demo/snack_bar_demo.dart
+1
-1
tabs_demo.dart
examples/flutter_gallery/lib/demo/tabs_demo.dart
+1
-1
tooltip_demo.dart
examples/flutter_gallery/lib/demo/tooltip_demo.dart
+1
-1
typography_demo.dart
examples/flutter_gallery/lib/demo/typography_demo.dart
+1
-1
drawer.dart
examples/flutter_gallery/lib/gallery/drawer.dart
+1
-1
example_code.dart
examples/flutter_gallery/lib/gallery/example_code.dart
+1
-1
media_query.dart
examples/layers/widgets/media_query.dart
+2
-2
stock_home.dart
examples/stocks/lib/stock_home.dart
+1
-1
stock_settings.dart
examples/stocks/lib/stock_settings.dart
+1
-1
grid_tile.dart
packages/flutter/lib/src/material/grid_tile.dart
+2
-2
stepper.dart
packages/flutter/lib/src/material/stepper.dart
+1
-1
two_level_list.dart
packages/flutter/lib/src/material/two_level_list.dart
+1
-1
scroll_view.dart
packages/flutter/lib/src/widgets/scroll_view.dart
+229
-51
single_child_scroll_view.dart
...ges/flutter/lib/src/widgets/single_child_scroll_view.dart
+25
-7
about_test.dart
packages/flutter/test/material/about_test.dart
+1
-1
drawer_test.dart
packages/flutter/test/material/drawer_test.dart
+1
-1
list_item_test.dart
packages/flutter/test/material/list_item_test.dart
+1
-1
progress_indicator_test.dart
packages/flutter/test/material/progress_indicator_test.dart
+2
-2
scrollbar_test.dart
packages/flutter/test/material/scrollbar_test.dart
+3
-3
slider_test.dart
packages/flutter/test/material/slider_test.dart
+1
-1
block_test.dart
packages/flutter/test/widgets/block_test.dart
+2
-2
center_test.dart
packages/flutter/test/widgets/center_test.dart
+1
-1
container_test.dart
packages/flutter/test/widgets/container_test.dart
+1
-1
date_picker_test.dart
packages/flutter/test/widgets/date_picker_test.dart
+1
-1
draggable_test.dart
packages/flutter/test/widgets/draggable_test.dart
+2
-2
drawer_test.dart
packages/flutter/test/widgets/drawer_test.dart
+1
-1
form_test.dart
packages/flutter/test/widgets/form_test.dart
+1
-1
heroes_test.dart
packages/flutter/test/widgets/heroes_test.dart
+4
-4
list_test.dart
packages/flutter/test/widgets/list_test.dart
+6
-6
reparent_state_test.dart
packages/flutter/test/widgets/reparent_state_test.dart
+1
-1
scroll_grid_test.dart
packages/flutter/test/widgets/scroll_grid_test.dart
+14
-14
scroll_view_test.dart
packages/flutter/test/widgets/scroll_view_test.dart
+8
-8
scrollable_dispose_test.dart
packages/flutter/test/widgets/scrollable_dispose_test.dart
+2
-2
scrollable_grid_test.dart
packages/flutter/test/widgets/scrollable_grid_test.dart
+4
-4
semantics_debugger_test.dart
packages/flutter/test/widgets/semantics_debugger_test.dart
+7
-7
No files found.
dev/benchmarks/complex_layout/lib/main.dart
View file @
332a2303
...
...
@@ -588,7 +588,7 @@ class GalleryDrawer extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
FancyDrawerHeader
(),
new
DrawerItem
(
...
...
dev/manual_tests/card_collection.dart
View file @
332a2303
...
...
@@ -123,7 +123,7 @@ class CardCollectionState extends State<CardCollection> {
return
new
Drawer
(
child:
new
IconTheme
(
data:
const
IconThemeData
(
color:
Colors
.
black
),
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
DrawerHeader
(
child:
new
Center
(
child:
new
Text
(
'Options'
))),
buildDrawerCheckbox
(
"Make card labels editable"
,
_editable
,
_toggleEditable
),
...
...
dev/manual_tests/pageable_list.dart
View file @
332a2303
...
...
@@ -84,7 +84,7 @@ class PageableListAppState extends State<PageableListApp> {
Widget
_buildDrawer
()
{
return
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
DrawerHeader
(
child:
new
Center
(
child:
new
Text
(
'Options'
))),
new
DrawerItem
(
...
...
examples/flutter_gallery/lib/demo/cards_demo.dart
View file @
332a2303
...
...
@@ -134,7 +134,7 @@ class CardsDemo extends StatelessWidget {
appBar:
new
AppBar
(
title:
new
Text
(
'Travel stream'
)
),
body:
new
Scroll
View
(
body:
new
List
View
(
itemExtent:
TravelDestinationItem
.
height
,
padding:
const
EdgeInsets
.
only
(
top:
8.0
,
left:
8.0
,
right:
8.0
),
children:
destinations
.
map
((
TravelDestination
destination
)
{
...
...
examples/flutter_gallery/lib/demo/chip_demo.dart
View file @
332a2303
...
...
@@ -41,7 +41,7 @@ class _ChipDemoState extends State<ChipDemo> {
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
'Chips'
)),
body:
new
Scroll
View
(
body:
new
List
View
(
children:
chips
.
map
((
Widget
widget
)
{
return
new
Container
(
height:
100.0
,
...
...
examples/flutter_gallery/lib/demo/colors_demo.dart
View file @
332a2303
...
...
@@ -98,7 +98,7 @@ class ColorSwatchTabView extends StatelessWidget {
}).
toList
());
}
return
new
Scroll
View
(
return
new
List
View
(
itemExtent:
kColorItemHeight
,
children:
colorItems
,
);
...
...
examples/flutter_gallery/lib/demo/data_table_demo.dart
View file @
332a2303
...
...
@@ -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
Scroll
View
(
body:
new
List
View
(
padding:
const
EdgeInsets
.
all
(
20.0
),
children:
<
Widget
>[
new
PaginatedDataTable
(
...
...
examples/flutter_gallery/lib/demo/dialog_demo.dart
View file @
332a2303
...
...
@@ -89,7 +89,7 @@ class DialogDemoState extends State<DialogDemo> {
appBar:
new
AppBar
(
title:
new
Text
(
'Dialogs'
)
),
body:
new
Scroll
View
(
body:
new
List
View
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
24.0
,
horizontal:
72.0
),
children:
<
Widget
>[
new
RaisedButton
(
...
...
examples/flutter_gallery/lib/demo/drawer_demo.dart
View file @
332a2303
...
...
@@ -88,7 +88,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
title:
new
Text
(
'Navigation drawer'
),
),
drawer:
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
UserAccountsDrawerHeader
(
accountName:
new
Text
(
'Zach Widget'
),
...
...
examples/flutter_gallery/lib/demo/full_screen_dialog_demo.dart
View file @
332a2303
...
...
@@ -157,7 +157,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
)
]
),
body:
new
Scroll
View
(
body:
new
List
View
(
padding:
const
EdgeInsets
.
all
(
16.0
),
children:
<
Widget
>[
new
Container
(
...
...
examples/flutter_gallery/lib/demo/grid_list_demo.dart
View file @
332a2303
...
...
@@ -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
,
...
...
examples/flutter_gallery/lib/demo/leave_behind_demo.dart
View file @
332a2303
...
...
@@ -161,7 +161,7 @@ class LeaveBehindDemoState extends State<LeaveBehindDemo> {
)
]
),
body:
new
Scroll
View
(
body:
new
List
View
(
children:
leaveBehindItems
.
map
(
buildItem
).
toList
()
)
);
...
...
examples/flutter_gallery/lib/demo/list_demo.dart
View file @
332a2303
...
...
@@ -40,7 +40,7 @@ class ListDemoState extends State<ListDemo> {
decoration:
new
BoxDecoration
(
border:
new
Border
(
top:
new
BorderSide
(
color:
Colors
.
black26
))
),
child:
new
Scroll
View
(
child:
new
List
View
(
shrinkWrap:
true
,
children:
<
Widget
>[
new
ListItem
(
...
...
examples/flutter_gallery/lib/demo/menu_demo.dart
View file @
332a2303
...
...
@@ -83,7 +83,7 @@ class MenuDemoState extends State<MenuDemo> {
)
]
),
body:
new
Scroll
View
(
body:
new
List
View
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8.0
),
children:
<
Widget
>[
// Pressing the PopupMenuButton on the right of this item shows
...
...
examples/flutter_gallery/lib/demo/snack_bar_demo.dart
View file @
332a2303
...
...
@@ -29,7 +29,7 @@ class _SnackBarDemoState extends State<SnackBarDemo> {
int
_snackBarIndex
=
1
;
Widget
buildBody
(
BuildContext
context
)
{
return
new
Scroll
View
(
return
new
List
View
(
padding:
const
EdgeInsets
.
all
(
24.0
),
children:
<
Widget
>[
new
Text
(
_text1
),
...
...
examples/flutter_gallery/lib/demo/tabs_demo.dart
View file @
332a2303
...
...
@@ -127,7 +127,7 @@ class TabsDemo extends StatelessWidget {
),
body:
new
TabBarView
(
children:
_allPages
.
keys
.
map
((
_Page
page
)
{
return
new
Scroll
View
(
return
new
List
View
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8.0
,
horizontal:
16.0
),
itemExtent:
_CardDataItem
.
height
,
children:
_allPages
[
page
].
map
((
_CardData
data
)
{
...
...
examples/flutter_gallery/lib/demo/tooltip_demo.dart
View file @
332a2303
...
...
@@ -22,7 +22,7 @@ class TooltipDemo extends StatelessWidget {
),
body:
new
Builder
(
builder:
(
BuildContext
context
)
{
return
new
Scroll
View
(
return
new
List
View
(
children:
<
Widget
>[
new
Text
(
_introText
,
style:
theme
.
textTheme
.
subhead
),
new
Row
(
...
...
examples/flutter_gallery/lib/demo/typography_demo.dart
View file @
332a2303
...
...
@@ -66,7 +66,7 @@ class TypographyDemo extends StatelessWidget {
return
new
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
'Typography'
)),
body:
new
Scroll
View
(
children:
styleItems
)
body:
new
List
View
(
children:
styleItems
)
);
}
}
examples/flutter_gallery/lib/gallery/drawer.dart
View file @
332a2303
...
...
@@ -305,6 +305,6 @@ class GalleryDrawer extends StatelessWidget {
));
}
return
new
Drawer
(
child:
new
Scroll
View
(
children:
allDrawerItems
));
return
new
Drawer
(
child:
new
List
View
(
children:
allDrawerItems
));
}
}
examples/flutter_gallery/lib/gallery/example_code.dart
View file @
332a2303
...
...
@@ -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
),
...
...
examples/layers/widgets/media_query.dart
View file @
332a2303
...
...
@@ -76,12 +76,12 @@ class AdaptiveContainer extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
if
(
MediaQuery
.
of
(
context
).
size
.
width
<
_kGridViewBreakpoint
)
{
return
new
Scroll
View
(
return
new
List
View
(
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
(),
);
...
...
examples/stocks/lib/stock_home.dart
View file @
332a2303
...
...
@@ -121,7 +121,7 @@ class StockHomeState extends State<StockHome> {
Widget
_buildDrawer
(
BuildContext
context
)
{
return
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
DrawerHeader
(
child:
new
Center
(
child:
new
Text
(
'Stocks'
))),
new
DrawerItem
(
...
...
examples/stocks/lib/stock_settings.dart
View file @
332a2303
...
...
@@ -240,7 +240,7 @@ class StockSettingsState extends State<StockSettings> {
]);
return
true
;
});
return
new
Scroll
View
(
return
new
List
View
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
20.0
),
children:
rows
,
);
...
...
packages/flutter/lib/src/material/grid_tile.dart
View file @
332a2303
...
...
@@ -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>
...
...
packages/flutter/lib/src/material/stepper.dart
View file @
332a2303
...
...
@@ -542,7 +542,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
);
}
return
new
Scroll
View
(
return
new
List
View
(
shrinkWrap:
true
,
children:
children
,
);
...
...
packages/flutter/lib/src/material/two_level_list.dart
View file @
332a2303
...
...
@@ -283,7 +283,7 @@ class TwoLevelList extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
return
new
Scroll
View
(
return
new
List
View
(
padding:
padding
,
shrinkWrap:
true
,
children:
KeyedSubtree
.
ensureUniqueKeysForList
(
children
),
...
...
packages/flutter/lib/src/widgets/scroll_view.dart
View file @
332a2303
...
...
@@ -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
);
...
...
packages/flutter/lib/src/widgets/single_child_scroll_view.dart
View file @
332a2303
...
...
@@ -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
,
...
...
packages/flutter/test/material/about_test.dart
View file @
332a2303
...
...
@@ -18,7 +18,7 @@ void main() {
title:
new
Text
(
'Home'
),
),
drawer:
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
AboutDrawerItem
(
applicationVersion:
'0.1.2'
,
...
...
packages/flutter/test/material/drawer_test.dart
View file @
332a2303
...
...
@@ -12,7 +12,7 @@ void main() {
await
tester
.
pumpWidget
(
new
Scaffold
(
drawer:
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
DrawerHeader
(
child:
new
Container
(
...
...
packages/flutter/test/material/list_item_test.dart
View file @
332a2303
...
...
@@ -32,7 +32,7 @@ void main() {
home:
new
Material
(
child:
new
Builder
(
builder:
(
BuildContext
context
)
{
return
new
Scroll
View
(
return
new
List
View
(
children:
ListItem
.
divideItems
(
context:
context
,
items:
titles
.
map
((
String
title
)
=>
new
ListItem
(
title:
new
Text
(
title
))),
...
...
packages/flutter/test/material/progress_indicator_test.dart
View file @
332a2303
...
...
@@ -50,9 +50,9 @@ void main() {
});
testWidgets
(
'LinearProgressIndicator causes a repaint when it changes'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Scroll
View
(
children:
<
Widget
>[
new
LinearProgressIndicator
(
value:
0.0
)]));
await
tester
.
pumpWidget
(
new
List
View
(
children:
<
Widget
>[
new
LinearProgressIndicator
(
value:
0.0
)]));
List
<
Layer
>
layers1
=
tester
.
layers
;
await
tester
.
pumpWidget
(
new
Scroll
View
(
children:
<
Widget
>[
new
LinearProgressIndicator
(
value:
0.5
)]));
await
tester
.
pumpWidget
(
new
List
View
(
children:
<
Widget
>[
new
LinearProgressIndicator
(
value:
0.5
)]));
List
<
Layer
>
layers2
=
tester
.
layers
;
expect
(
layers1
,
isNot
(
equals
(
layers2
)));
});
...
...
packages/flutter/test/material/scrollbar_test.dart
View file @
332a2303
...
...
@@ -17,7 +17,7 @@ void main() {
height:
200.0
,
width:
300.0
,
child:
new
Scrollbar2
(
child:
new
Scroll
View
(
child:
new
List
View
(
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
(
Scroll
View
));
await
tester
.
tap
(
find
.
byType
(
List
View
));
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
(
Scroll
View
),
const
Offset
(
0.0
,
-
10.0
));
await
tester
.
scroll
(
find
.
byType
(
List
View
),
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
));
...
...
packages/flutter/test/material/slider_test.dart
View file @
332a2303
...
...
@@ -115,7 +115,7 @@ void main() {
(
WidgetTester
tester
)
async
{
double
value
=
0.0
;
await
tester
.
pumpWidget
(
new
Material
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
Slider
(
value:
value
,
...
...
packages/flutter/test/widgets/block_test.dart
View file @
332a2303
...
...
@@ -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
Scroll
View
(
new
List
View
(
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
Scroll
View
(
new
List
View
(
key:
blockKey
,
children:
<
Widget
>[
new
Container
(
...
...
packages/flutter/test/widgets/center_test.dart
View file @
332a2303
...
...
@@ -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
Scroll
View
(
children:
<
Widget
>[
new
Center
()]));
await
tester
.
pumpWidget
(
new
List
View
(
children:
<
Widget
>[
new
Center
()]));
});
}
packages/flutter/test/widgets/container_test.dart
View file @
332a2303
...
...
@@ -50,6 +50,6 @@ void main() {
});
testWidgets
(
'Can be placed in an infinite box'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Scroll
View
(
children:
<
Widget
>[
new
Container
()]));
await
tester
.
pumpWidget
(
new
List
View
(
children:
<
Widget
>[
new
Container
()]));
});
}
packages/flutter/test/widgets/date_picker_test.dart
View file @
332a2303
...
...
@@ -10,7 +10,7 @@ void main() {
DateTime
currentValue
;
Widget
widget
=
new
Material
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
MonthPicker
(
selectedDate:
new
DateTime
.
utc
(
2015
,
6
,
9
,
7
,
12
),
...
...
packages/flutter/test/widgets/draggable_test.dart
View file @
332a2303
...
...
@@ -312,7 +312,7 @@ void main() {
Point
firstLocation
,
secondLocation
,
thirdLocation
;
await
tester
.
pumpWidget
(
new
MaterialApp
(
home:
new
Scroll
View
(
home:
new
List
View
(
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
Scroll
View
(
home:
new
List
View
(
scrollDirection:
Axis
.
horizontal
,
children:
<
Widget
>[
new
DragTarget
<
int
>(
...
...
packages/flutter/test/widgets/drawer_test.dart
View file @
332a2303
...
...
@@ -135,7 +135,7 @@ void main() {
return
new
Scaffold
(
key:
scaffoldKey
,
drawer:
new
Drawer
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
Text
(
'drawer'
),
new
FlatButton
(
...
...
packages/flutter/test/widgets/form_test.dart
View file @
332a2303
...
...
@@ -149,7 +149,7 @@ void main() {
autovalidate:
true
,
child:
new
Focus
(
key:
focusKey
,
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
TextField
(
key:
fieldKey
...
...
packages/flutter/test/widgets/heroes_test.dart
View file @
332a2303
...
...
@@ -11,7 +11,7 @@ Key thirdKey = new Key('third');
final
Map
<
String
,
WidgetBuilder
>
routes
=
<
String
,
WidgetBuilder
>{
'/'
:
(
BuildContext
context
)
=>
new
Material
(
child:
new
Scroll
View
(
child:
new
List
View
(
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
Scroll
View
(
child:
new
List
View
(
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
Scroll
View
(
child:
new
List
View
(
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
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
Hero
(
tag:
'a'
,
child:
new
Text
(
'foo'
)),
new
Builder
(
builder:
(
BuildContext
context
)
{
...
...
packages/flutter/test/widgets/list_test.dart
View file @
332a2303
...
...
@@ -6,9 +6,9 @@ import 'package:flutter_test/flutter_test.dart';
import
'package:flutter/widgets.dart'
;
void
main
(
)
{
testWidgets
(
'
Scroll
View itemExtent control test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'
List
View itemExtent control test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
new
Scroll
View
(
new
List
View
(
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
(
Scroll
View
),
const
Offset
(
0.0
,
-
250.0
));
await
tester
.
scroll
(
find
.
byType
(
List
View
),
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
(
Scroll
View
),
const
Offset
(
0.0
,
200.0
));
await
tester
.
scroll
(
find
.
byType
(
List
View
),
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
(
'
Scroll
View large scroll jump'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'
List
View large scroll jump'
,
(
WidgetTester
tester
)
async
{
List
<
int
>
log
=
<
int
>[];
await
tester
.
pumpWidget
(
new
Scroll
View
(
new
List
View
(
itemExtent:
200.0
,
children:
new
List
<
Widget
>.
generate
(
20
,
(
int
i
)
{
return
new
Builder
(
...
...
packages/flutter/test/widgets/reparent_state_test.dart
View file @
332a2303
...
...
@@ -195,7 +195,7 @@ void main() {
StateMarkerState
keyState
=
key
.
currentState
;
keyState
.
marker
=
"marked"
;
await
tester
.
pumpWidget
(
new
Scroll
View
(
await
tester
.
pumpWidget
(
new
List
View
(
itemExtent:
100.0
,
children:
<
Widget
>[
new
Container
(
...
...
packages/flutter/test/widgets/scroll_grid_test.dart
View file @
332a2303
...
...
@@ -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
,
),
...
...
packages/flutter/test/widgets/scroll_view_test.dart
View file @
332a2303
...
...
@@ -8,10 +8,10 @@ import 'package:flutter/widgets.dart';
import
'states.dart'
;
void
main
(
)
{
testWidgets
(
'
Scroll
View control test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'
List
View control test'
,
(
WidgetTester
tester
)
async
{
List
<
String
>
log
=
<
String
>[];
await
tester
.
pumpWidget
(
new
Scroll
View
(
await
tester
.
pumpWidget
(
new
List
View
(
children:
kStates
.
map
<
Widget
>((
String
state
)
{
return
new
GestureDetector
(
onTap:
()
{
...
...
@@ -45,9 +45,9 @@ void main() {
log
.
clear
();
});
testWidgets
(
'
Scroll
View restart ballistic activity out of range'
,
(
WidgetTester
tester
)
async
{
Widget
build
Scroll
View
(
int
n
)
{
return
new
Scroll
View
(
testWidgets
(
'
List
View restart ballistic activity out of range'
,
(
WidgetTester
tester
)
async
{
Widget
build
List
View
(
int
n
)
{
return
new
List
View
(
children:
kStates
.
take
(
n
).
map
<
Widget
>((
String
state
)
{
return
new
Container
(
height:
200.0
,
...
...
@@ -60,9 +60,9 @@ void main() {
);
}
await
tester
.
pumpWidget
(
build
Scroll
View
(
30
));
await
tester
.
fling
(
find
.
byType
(
Scroll
View
),
const
Offset
(
0.0
,
-
4000.0
),
4000.0
);
await
tester
.
pumpWidget
(
build
Scroll
View
(
15
));
await
tester
.
pumpWidget
(
build
List
View
(
30
));
await
tester
.
fling
(
find
.
byType
(
List
View
),
const
Offset
(
0.0
,
-
4000.0
),
4000.0
);
await
tester
.
pumpWidget
(
build
List
View
(
15
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
...
...
packages/flutter/test/widgets/scrollable_dispose_test.dart
View file @
332a2303
...
...
@@ -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
Scroll
View
(
children:
textWidgets
),
left:
new
List
View
(
children:
textWidgets
),
right:
new
Container
()
));
await
tester
.
fling
(
find
.
byType
(
Scroll
View
),
const
Offset
(
0.0
,
-
200.0
),
1000.0
);
await
tester
.
fling
(
find
.
byType
(
List
View
),
const
Offset
(
0.0
,
-
200.0
),
1000.0
);
await
tester
.
pump
();
tester
.
state
<
FlipWidgetState
>(
find
.
byType
(
FlipWidget
)).
flip
();
...
...
packages/flutter/test/widgets/scrollable_grid_test.dart
View file @
332a2303
...
...
@@ -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
)
{
...
...
packages/flutter/test/widgets/semantics_debugger_test.dart
View file @
332a2303
...
...
@@ -126,7 +126,7 @@ void main() {
await
tester
.
pumpWidget
(
new
SemanticsDebugger
(
child:
new
Material
(
child:
new
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
RaisedButton
(
onPressed:
()
{
...
...
@@ -160,7 +160,7 @@ void main() {
await
tester
.
pumpWidget
(
new
SemanticsDebugger
(
child:
new
Scroll
View
(
child:
new
List
View
(
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
(
Scroll
View
),
const
Offset
(
0.0
,
-
200.0
),
200.0
);
await
tester
.
fling
(
find
.
byType
(
List
View
),
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
(
Scroll
View
),
const
Offset
(
200.0
,
0.0
),
200.0
);
await
tester
.
fling
(
find
.
byType
(
List
View
),
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
(
Scroll
View
),
const
Offset
(-
200.0
,
0.0
),
200.0
);
await
tester
.
fling
(
find
.
byType
(
List
View
),
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
(
Scroll
View
),
const
Offset
(
0.0
,
200.0
),
200.0
);
await
tester
.
fling
(
find
.
byType
(
List
View
),
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
Scroll
View
(
child:
new
List
View
(
children:
<
Widget
>[
new
Checkbox
(
key:
keyTop
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment