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
7939ec5d
Commit
7939ec5d
authored
Nov 12, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #336 from abarth/builder_index
ItemBuilder should also get the index of the item
parents
0758fea1
0259ad81
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
17 additions
and
17 deletions
+17
-17
feed.dart
examples/fitness/lib/feed.dart
+1
-1
stock_list.dart
examples/stocks/lib/stock_list.dart
+1
-1
card_collection.dart
examples/widgets/card_collection.dart
+1
-1
pageable_list.dart
examples/widgets/pageable_list.dart
+1
-1
scrollbar.dart
examples/widgets/scrollbar.dart
+3
-3
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+2
-2
dismissable_test.dart
packages/unit/test/widget/dismissable_test.dart
+1
-1
pageable_list_test.dart
packages/unit/test/widget/pageable_list_test.dart
+1
-1
reparent_state_test.dart
packages/unit/test/widget/reparent_state_test.dart
+1
-1
scrollable_list_hit_testing_test.dart
...es/unit/test/widget/scrollable_list_hit_testing_test.dart
+2
-2
scrollable_list_horizontal_test.dart
...ges/unit/test/widget/scrollable_list_horizontal_test.dart
+1
-1
scrollable_list_vertical_test.dart
packages/unit/test/widget/scrollable_list_vertical_test.dart
+1
-1
snap_scrolling_test.dart
packages/unit/test/widget/snap_scrolling_test.dart
+1
-1
No files found.
examples/fitness/lib/feed.dart
View file @
7939ec5d
...
...
@@ -18,7 +18,7 @@ class FitnessItemList extends StatelessComponent {
padding:
const
EdgeDims
.
all
(
4.0
),
items:
items
,
itemExtent:
kFitnessItemHeight
,
itemBuilder:
(
BuildContext
context
,
FitnessItem
item
)
=>
item
.
toRow
(
onDismissed:
onDismissed
)
itemBuilder:
(
BuildContext
context
,
FitnessItem
item
,
int
index
)
=>
item
.
toRow
(
onDismissed:
onDismissed
)
);
}
}
...
...
examples/stocks/lib/stock_list.dart
View file @
7939ec5d
...
...
@@ -16,7 +16,7 @@ class StockList extends StatelessComponent {
return
new
ScrollableList
<
Stock
>(
items:
stocks
,
itemExtent:
StockRow
.
kHeight
,
itemBuilder:
(
BuildContext
context
,
Stock
stock
)
{
itemBuilder:
(
BuildContext
context
,
Stock
stock
,
int
index
)
{
return
new
StockRow
(
stock:
stock
,
onPressed:
onOpen
,
...
...
examples/widgets/card_collection.dart
View file @
7939ec5d
...
...
@@ -400,7 +400,7 @@ class CardCollectionState extends State<CardCollection> {
snapOffsetCallback:
_snapToCenter
?
_toSnapOffset
:
null
,
snapAlignmentOffset:
_cardCollectionSize
.
height
/
2.0
,
items:
_cardModels
,
itemBuilder:
(
BuildContext
context
,
CardModel
card
)
=>
buildCard
(
context
,
card
.
value
),
itemBuilder:
(
BuildContext
context
,
CardModel
card
,
int
index
)
=>
buildCard
(
context
,
card
.
value
),
itemExtent:
_cardModels
[
0
].
height
);
}
else
{
...
...
examples/widgets/pageable_list.dart
View file @
7939ec5d
...
...
@@ -47,7 +47,7 @@ class PageableListAppState extends State<PageableListApp> {
});
}
Widget
buildCard
(
BuildContext
context
,
CardModel
cardModel
)
{
Widget
buildCard
(
BuildContext
context
,
CardModel
cardModel
,
int
index
)
{
Widget
card
=
new
Card
(
color:
cardModel
.
color
,
child:
new
Container
(
...
...
examples/widgets/scrollbar.dart
View file @
7939ec5d
...
...
@@ -19,9 +19,9 @@ class ScrollbarAppState extends State<ScrollbarApp> {
return
new
ScrollableList
<
int
>(
items:
new
List
<
int
>.
generate
(
_itemCount
,
(
int
i
)
=>
i
),
itemExtent:
_itemExtent
,
itemBuilder:
(
_
,
int
i
)
{
return
new
Text
(
'Item
${dd.format(i)}
'
,
key:
new
ValueKey
<
int
>(
i
),
itemBuilder:
(
_
,
__
,
int
index
)
{
return
new
Text
(
'Item
${dd.format(i
ndex
)}
'
,
key:
new
ValueKey
<
int
>(
i
ndex
),
style:
Theme
.
of
(
context
).
text
.
title
);
},
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
7939ec5d
...
...
@@ -632,7 +632,7 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
}
typedef
Widget
ItemBuilder
<
T
>(
BuildContext
context
,
T
item
);
typedef
Widget
ItemBuilder
<
T
>(
BuildContext
context
,
T
item
,
int
index
);
/// A wrapper around [ScrollableWidgetList] that helps you translate a list of
/// model objects into a scrollable list of widgets. Assumes all the widgets
...
...
@@ -682,7 +682,7 @@ class ScrollableListState<T, Config extends ScrollableList<T>> extends Scrollabl
int
begin
=
config
.
itemsWrap
?
start
:
math
.
max
(
0
,
start
);
int
end
=
config
.
itemsWrap
?
begin
+
count
:
math
.
min
(
begin
+
count
,
config
.
items
.
length
);
for
(
int
i
=
begin
;
i
<
end
;
++
i
)
result
.
add
(
config
.
itemBuilder
(
context
,
config
.
items
[
i
%
itemCount
]));
result
.
add
(
config
.
itemBuilder
(
context
,
config
.
items
[
i
%
itemCount
]
,
i
));
return
result
;
}
}
...
...
packages/unit/test/widget/dismissable_test.dart
View file @
7939ec5d
...
...
@@ -19,7 +19,7 @@ void handleOnDismissed(item) {
dismissedItems
.
add
(
item
);
}
Widget
buildDismissableItem
(
BuildContext
context
,
int
item
)
{
Widget
buildDismissableItem
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Dismissable
(
key:
new
ValueKey
<
int
>(
item
),
direction:
dismissDirection
,
...
...
packages/unit/test/widget/pageable_list_test.dart
View file @
7939ec5d
...
...
@@ -8,7 +8,7 @@ const List<int> pages = const <int>[0, 1, 2, 3, 4, 5];
int
currentPage
=
null
;
bool
itemsWrap
=
false
;
Widget
buildPage
(
BuildContext
context
,
int
page
)
{
Widget
buildPage
(
BuildContext
context
,
int
page
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
page
),
width:
pageSize
.
width
,
...
...
packages/unit/test/widget/reparent_state_test.dart
View file @
7939ec5d
...
...
@@ -103,7 +103,7 @@ void main() {
tester
.
pumpWidget
(
new
ScrollableList
<
int
>(
items:
<
int
>[
0
],
itemExtent:
100.0
,
itemBuilder:
(
BuildContext
context
,
int
item
)
{
itemBuilder:
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Container
(
key:
new
Key
(
'container'
),
height:
100.0
,
...
...
packages/unit/test/widget/scrollable_list_hit_testing_test.dart
View file @
7939ec5d
...
...
@@ -17,7 +17,7 @@ void main() {
child:
new
ScrollableList
<
int
>(
key:
new
GlobalKey
(),
items:
items
,
itemBuilder:
(
BuildContext
context
,
int
item
)
{
itemBuilder:
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
item
),
child:
new
GestureDetector
(
...
...
@@ -59,7 +59,7 @@ void main() {
child:
new
ScrollableList
<
int
>(
key:
new
GlobalKey
(),
items:
items
,
itemBuilder:
(
BuildContext
context
,
int
item
)
{
itemBuilder:
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
item
),
child:
new
GestureDetector
(
...
...
packages/unit/test/widget/scrollable_list_horizontal_test.dart
View file @
7939ec5d
...
...
@@ -12,7 +12,7 @@ Widget buildFrame() {
height:
50.0
,
child:
new
ScrollableList
<
int
>(
items:
items
,
itemBuilder:
(
BuildContext
context
,
int
item
)
{
itemBuilder:
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
item
),
child:
new
Text
(
'
$item
'
)
...
...
packages/unit/test/widget/scrollable_list_vertical_test.dart
View file @
7939ec5d
...
...
@@ -8,7 +8,7 @@ const List<int> items = const <int>[0, 1, 2, 3, 4, 5];
Widget
buildFrame
(
)
{
return
new
ScrollableList
<
int
>(
items:
items
,
itemBuilder:
(
BuildContext
context
,
int
item
)
{
itemBuilder:
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
item
),
child:
new
Text
(
'
$item
'
)
...
...
packages/unit/test/widget/snap_scrolling_test.dart
View file @
7939ec5d
...
...
@@ -13,7 +13,7 @@ const double itemExtent = 200.0;
ScrollDirection
scrollDirection
=
ScrollDirection
.
vertical
;
GlobalKey
scrollableListKey
;
Widget
buildItem
(
BuildContext
context
,
int
item
)
{
Widget
buildItem
(
BuildContext
context
,
int
item
,
int
index
)
{
return
new
Container
(
key:
new
ValueKey
<
int
>(
item
),
width:
itemExtent
,
...
...
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