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
b63bcaa3
Unverified
Commit
b63bcaa3
authored
Jun 23, 2021
by
Xavier H
Committed by
GitHub
Jun 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ListTile.divideTiles only run Iterable once (#78879)
parent
69f2f8a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
5 deletions
+19
-5
list_tile.dart
packages/flutter/lib/src/material/list_tile.dart
+5
-5
list_tile_test.dart
packages/flutter/test/material/list_tile_test.dart
+14
-0
No files found.
packages/flutter/lib/src/material/list_tile.dart
View file @
b63bcaa3
...
...
@@ -980,11 +980,11 @@ class ListTile extends StatelessWidget {
assert
(
tiles
!=
null
);
assert
(
color
!=
null
||
context
!=
null
);
if
(
tiles
.
isEmpty
)
return
;
final
Iterator
<
Widget
>
iterator
=
tiles
.
iterator
;
final
bool
isNotEmpty
=
iterator
.
moveNext
();
final
bool
hasNext
=
iterator
.
moveNext
();
if
(!
hasNext
)
return
;
final
Decoration
decoration
=
BoxDecoration
(
border:
Border
(
...
...
@@ -1001,7 +1001,7 @@ class ListTile extends StatelessWidget {
);
tile
=
iterator
.
current
;
}
if
(
isNotEmpty
)
if
(
hasNext
)
yield
tile
;
}
...
...
packages/flutter/test/material/list_tile_test.dart
View file @
b63bcaa3
...
...
@@ -257,6 +257,20 @@ void main() {
expect
(
output
,
isEmpty
);
});
testWidgets
(
'ListTile.divideTiles only runs the generator once'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/pull/78879
int
callCount
=
0
;
Iterable
<
Widget
>
generator
()
sync
*
{
callCount
+=
1
;
yield
const
Text
(
''
);
yield
const
Text
(
''
);
}
final
List
<
Widget
>
output
=
ListTile
.
divideTiles
(
tiles:
generator
(),
color:
Colors
.
grey
).
toList
();
expect
(
output
,
hasLength
(
2
));
expect
(
callCount
,
1
);
});
testWidgets
(
'ListTileTheme'
,
(
WidgetTester
tester
)
async
{
final
Key
titleKey
=
UniqueKey
();
final
Key
subtitleKey
=
UniqueKey
();
...
...
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