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
a8b4e938
Commit
a8b4e938
authored
Mar 21, 2016
by
Hans Muller
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2796 from HansMuller/ali_demo
Fix _LazyWidgetProvider indexing, move Ali Connors
parents
24bf14c5
70550a7a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
2 deletions
+52
-2
home.dart
examples/material_gallery/lib/gallery/home.dart
+2
-0
virtual_viewport.dart
packages/flutter/lib/src/widgets/virtual_viewport.dart
+3
-2
scrollable_lazy_list_test.dart
packages/flutter/test/widget/scrollable_lazy_list_test.dart
+47
-0
No files found.
examples/material_gallery/lib/gallery/home.dart
View file @
a8b4e938
...
...
@@ -17,6 +17,7 @@ import '../demo/date_picker_demo.dart';
import
'../demo/dialog_demo.dart'
;
import
'../demo/drop_down_demo.dart'
;
import
'../demo/fitness_demo.dart'
;
import
'../demo/flexible_space_demo.dart'
;
import
'../demo/grid_list_demo.dart'
;
import
'../demo/icons_demo.dart'
;
import
'../demo/leave_behind_demo.dart'
;
...
...
@@ -103,6 +104,7 @@ class GalleryHomeState extends State<GalleryHome> {
image:
'assets/section_components.png'
,
colors:
Colors
.
amber
,
demos:
<
GalleryDemo
>[
new
GalleryDemo
(
title:
'App Bar'
,
builder:
()
=>
new
FlexibleSpaceDemo
()),
new
GalleryDemo
(
title:
'Buttons'
,
builder:
()
=>
new
ButtonsDemo
()),
new
GalleryDemo
(
title:
'Buttons: Floating Action Button'
,
builder:
()
=>
new
TabsFabDemo
()),
new
GalleryDemo
(
title:
'Cards'
,
builder:
()
=>
new
CardsDemo
()),
...
...
packages/flutter/lib/src/widgets/virtual_viewport.dart
View file @
a8b4e938
...
...
@@ -297,7 +297,8 @@ class _LazyWidgetProvider extends _WidgetProvider {
@override
Widget
getChild
(
int
i
)
{
int
n
=
_length
??
_widgets
.
length
;
return
_widgets
[(
i
%
n
).
abs
()];
final
int
childCount
=
virtualChildCount
;
final
int
index
=
childCount
!=
null
?
(
i
%
childCount
).
abs
()
:
i
;
return
_widgets
[
index
-
_base
];
}
}
packages/flutter/test/widget/scrollable_lazy_list_test.dart
View file @
a8b4e938
...
...
@@ -158,4 +158,51 @@ void main() {
callbackTracker
.
clear
();
});
});
test
(
'ScrollableLazyList 10 items, 2-3 items visible'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
List
<
int
>
callbackTracker
=
<
int
>[];
// The root view is 800x600 in the test environment and our list
// items are 300 tall. Scrolling should cause two or three items
// to be built.
ItemListBuilder
itemBuilder
=
(
BuildContext
context
,
int
start
,
int
count
)
{
List
<
Widget
>
result
=
<
Widget
>[];
for
(
int
index
=
start
;
index
<
start
+
count
;
index
+=
1
)
{
callbackTracker
.
add
(
index
);
result
.
add
(
new
Text
(
'
$index
'
,
key:
new
ValueKey
<
int
>(
index
)));
}
return
result
;
};
GlobalKey
<
ScrollableState
<
ScrollableLazyList
>>
scrollableKey
=
new
GlobalKey
<
ScrollableState
<
ScrollableLazyList
>>();
Widget
testWidget
=
new
ScrollableLazyList
(
key:
scrollableKey
,
itemBuilder:
itemBuilder
,
itemExtent:
300.0
,
itemCount:
10
);
tester
.
pumpWidget
(
testWidget
);
expect
(
callbackTracker
,
equals
([
0
,
1
]));
callbackTracker
.
clear
();
scrollableKey
.
currentState
.
scrollTo
(
150.0
);
tester
.
pumpWidget
(
testWidget
);
expect
(
callbackTracker
,
equals
([
0
,
1
,
2
]));
callbackTracker
.
clear
();
scrollableKey
.
currentState
.
scrollTo
(
600.0
);
tester
.
pumpWidget
(
testWidget
);
expect
(
callbackTracker
,
equals
([
2
,
3
]));
callbackTracker
.
clear
();
scrollableKey
.
currentState
.
scrollTo
(
750.0
);
tester
.
pumpWidget
(
testWidget
);
expect
(
callbackTracker
,
equals
([
2
,
3
,
4
]));
callbackTracker
.
clear
();
});
});
}
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