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
5e2d32fe
Unverified
Commit
5e2d32fe
authored
Jun 22, 2021
by
Darren Austin
Committed by
GitHub
Jun 22, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed an issue with overflow exceptions with nested lists inside a reorderable list item. (#84807)
parent
2c9de5ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
reorderable_list.dart
packages/flutter/lib/src/widgets/reorderable_list.dart
+1
-1
reorderable_list_test.dart
packages/flutter/test/widgets/reorderable_list_test.dart
+46
-0
No files found.
packages/flutter/lib/src/widgets/reorderable_list.dart
View file @
5e2d32fe
...
...
@@ -673,7 +673,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
setState
(()
{
if
(
_insertIndex
!
<
widget
.
itemCount
-
1
)
{
// Find the location of the item we want to insert before
_finalDropPosition
=
_itemOffsetAt
(
_insertIndex
!);
_finalDropPosition
=
_itemOffsetAt
(
_insertIndex
!
+
(
_reverse
?
1
:
0
)
);
}
else
{
// Inserting into the last spot on the list. If it's the only spot, put
// it back where it was. Otherwise, grab the second to last and move
...
...
packages/flutter/test/widgets/reorderable_list_test.dart
View file @
5e2d32fe
...
...
@@ -268,6 +268,49 @@ void main() {
expect
(
getItemFadeTransition
(),
findsNothing
);
});
testWidgets
(
'SliverReorderableList - properly animates the drop at starting position in a reversed list'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/84625
final
List
<
int
>
items
=
List
<
int
>.
generate
(
8
,
(
int
index
)
=>
index
);
Future
<
void
>
pressDragRelease
(
Offset
start
,
Offset
delta
)
async
{
final
TestGesture
drag
=
await
tester
.
startGesture
(
start
);
await
tester
.
pump
(
kPressTimeout
);
await
drag
.
moveBy
(
delta
);
await
tester
.
pumpAndSettle
();
await
drag
.
up
();
await
tester
.
pump
();
}
// The TestList is 800x600 SliverReorderableList with 8 items 800x100 each.
// Each item has a text widget with 'item $index' that can be moved by a
// press and drag gesture. For this test we are reversing the order so
// the first item is at the bottom.
await
tester
.
pumpWidget
(
TestList
(
items:
items
,
reverse:
true
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 0'
)),
const
Offset
(
0
,
500
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 1'
)),
const
Offset
(
0
,
400
));
// Drag item 0 downwards off the edge and let it snap back. It should
// smoothly animate back up.
await
pressDragRelease
(
tester
.
getCenter
(
find
.
text
(
'item 0'
)),
const
Offset
(
0
,
50
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 0'
)),
const
Offset
(
0
,
550
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 1'
)),
const
Offset
(
0
,
400
));
// After the first several frames we should be moving closer to the final position,
// not further away as was the case with the original bug.
await
tester
.
pump
(
const
Duration
(
milliseconds:
10
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 0'
)).
dy
,
lessThan
(
550
));
// Sample the middle (don't use exact values as it depends on the internal
// curve being used).
await
tester
.
pump
(
const
Duration
(
milliseconds:
125
));
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 0'
)).
dy
,
lessThan
(
550
));
// Wait for it to finish, it should be back to the original position
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getTopLeft
(
find
.
text
(
'item 0'
)),
const
Offset
(
0
,
500
));
});
testWidgets
(
'ReorderableList asserts on both non-null itemExtent and prototypeItem'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
numbers
=
<
int
>[
0
,
1
,
2
];
expect
(()
=>
ReorderableList
(
...
...
@@ -594,12 +637,14 @@ class TestList extends StatefulWidget {
this
.
iconColor
,
this
.
proxyDecorator
,
required
this
.
items
,
this
.
reverse
=
false
,
})
:
super
(
key:
key
);
final
List
<
int
>
items
;
final
Color
?
textColor
;
final
Color
?
iconColor
;
final
ReorderItemProxyDecorator
?
proxyDecorator
;
final
bool
reverse
;
@override
State
<
TestList
>
createState
()
=>
_TestListState
();
...
...
@@ -618,6 +663,7 @@ class _TestListState extends State<TestList> {
builder:
(
BuildContext
outerContext
,
StateSetter
setState
)
{
final
List
<
int
>
items
=
widget
.
items
;
return
CustomScrollView
(
reverse:
widget
.
reverse
,
slivers:
<
Widget
>[
SliverReorderableList
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
...
...
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