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
68d0c89f
Unverified
Commit
68d0c89f
authored
Jan 14, 2020
by
rami-a
Committed by
GitHub
Jan 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return the correct number of semantic children for the ListView.separated constructor (#48741)
parent
b3ea1914
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
4 deletions
+52
-4
scroll_view.dart
packages/flutter/lib/src/widgets/scroll_view.dart
+4
-4
list_view_builder_test.dart
packages/flutter/test/widgets/list_view_builder_test.dart
+48
-0
No files found.
packages/flutter/lib/src/widgets/scroll_view.dart
View file @
68d0c89f
...
...
@@ -1051,7 +1051,7 @@ class ListView extends BoxScrollView {
}
return
widget
;
},
childCount:
_compute
Semantic
ChildCount
(
itemCount
),
childCount:
_compute
Actual
ChildCount
(
itemCount
),
addAutomaticKeepAlives:
addAutomaticKeepAlives
,
addRepaintBoundaries:
addRepaintBoundaries
,
addSemanticIndexes:
addSemanticIndexes
,
...
...
@@ -1069,7 +1069,7 @@ class ListView extends BoxScrollView {
shrinkWrap:
shrinkWrap
,
padding:
padding
,
cacheExtent:
cacheExtent
,
semanticChildCount:
_computeSemanticChildCount
(
itemCount
)
,
semanticChildCount:
itemCount
,
);
/// Creates a scrollable, linear array of widgets with a custom child model.
...
...
@@ -1215,8 +1215,8 @@ class ListView extends BoxScrollView {
properties
.
add
(
DoubleProperty
(
'itemExtent'
,
itemExtent
,
defaultValue:
null
));
}
// Helper method to compute the
semantic
child count for the separated constructor.
static
int
_compute
Semantic
ChildCount
(
int
itemCount
)
{
// Helper method to compute the
actual
child count for the separated constructor.
static
int
_compute
Actual
ChildCount
(
int
itemCount
)
{
return
math
.
max
(
0
,
itemCount
*
2
-
1
);
}
}
...
...
packages/flutter/test/widgets/list_view_builder_test.dart
View file @
68d0c89f
...
...
@@ -304,6 +304,54 @@ void main() {
expect
(
find
.
text
(
's5'
),
findsNothing
);
expect
(
find
.
text
(
'i6'
),
findsNothing
);
});
testWidgets
(
'ListView.separated uses correct semanticChildCount'
,
(
WidgetTester
tester
)
async
{
Widget
buildFrame
({
int
itemCount
})
{
return
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
ListView
.
separated
(
itemCount:
itemCount
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
SizedBox
(
height:
100.0
,
child:
Text
(
'i
$index
'
),
);
},
separatorBuilder:
(
BuildContext
context
,
int
index
)
{
return
SizedBox
(
height:
10.0
,
child:
Text
(
's
$index
'
),
);
},
),
);
}
Scrollable
scrollable
()
{
return
tester
.
widget
<
Scrollable
>(
find
.
descendant
(
of:
find
.
byType
(
ListView
),
matching:
find
.
byType
(
Scrollable
),
),
);
}
await
tester
.
pumpWidget
(
buildFrame
(
itemCount:
0
));
expect
(
scrollable
().
semanticChildCount
,
0
);
await
tester
.
pumpWidget
(
buildFrame
(
itemCount:
1
));
expect
(
scrollable
().
semanticChildCount
,
1
);
await
tester
.
pumpWidget
(
buildFrame
(
itemCount:
2
));
expect
(
scrollable
().
semanticChildCount
,
2
);
await
tester
.
pumpWidget
(
buildFrame
(
itemCount:
3
));
expect
(
scrollable
().
semanticChildCount
,
3
);
await
tester
.
pumpWidget
(
buildFrame
(
itemCount:
4
));
expect
(
scrollable
().
semanticChildCount
,
4
);
});
}
void
check
(
{
List
<
int
>
visible
=
const
<
int
>[],
List
<
int
>
hidden
=
const
<
int
>[]
})
{
...
...
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