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
d29ccad6
Unverified
Commit
d29ccad6
authored
May 11, 2022
by
xubaolin
Committed by
GitHub
May 11, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix `SliverReorderableList` not work on Android platform bug (#103406)
parent
04318d88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
1 deletion
+60
-1
reorderable_list.dart
packages/flutter/lib/src/widgets/reorderable_list.dart
+3
-1
reorderable_list_test.dart
packages/flutter/test/widgets/reorderable_list_test.dart
+57
-0
No files found.
packages/flutter/lib/src/widgets/reorderable_list.dart
View file @
d29ccad6
...
...
@@ -1270,11 +1270,13 @@ class ReorderableDragStartListener extends StatelessWidget {
}
void
_startDragging
(
BuildContext
context
,
PointerDownEvent
event
)
{
final
DeviceGestureSettings
?
gestureSettings
=
MediaQuery
.
maybeOf
(
context
)?.
gestureSettings
;
final
SliverReorderableListState
?
list
=
SliverReorderableList
.
maybeOf
(
context
);
list
?.
startItemDragReorder
(
index:
index
,
event:
event
,
recognizer:
createRecognizer
(),
recognizer:
createRecognizer
()
..
gestureSettings
=
gestureSettings
,
);
}
}
...
...
packages/flutter/test/widgets/reorderable_list_test.dart
View file @
d29ccad6
...
...
@@ -7,6 +7,63 @@ import 'package:flutter/material.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
testWidgets
(
'SliverReorderableList works well when having gestureSettings'
,
(
WidgetTester
tester
)
async
{
// Regression test for https://github.com/flutter/flutter/issues/103404
const
int
itemCount
=
5
;
int
onReorderCallCount
=
0
;
final
List
<
int
>
items
=
List
<
int
>.
generate
(
itemCount
,
(
int
index
)
=>
index
);
void
handleReorder
(
int
fromIndex
,
int
toIndex
)
{
onReorderCallCount
+=
1
;
if
(
toIndex
>
fromIndex
)
{
toIndex
-=
1
;
}
items
.
insert
(
toIndex
,
items
.
removeAt
(
fromIndex
));
}
// The list has five elements of height 100
await
tester
.
pumpWidget
(
MaterialApp
(
home:
MediaQuery
(
data:
const
MediaQueryData
(
gestureSettings:
DeviceGestureSettings
(
touchSlop:
8.0
)),
child:
CustomScrollView
(
slivers:
<
Widget
>[
SliverReorderableList
(
itemCount:
itemCount
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
SizedBox
(
key:
ValueKey
<
int
>(
items
[
index
]),
height:
100
,
child:
ReorderableDragStartListener
(
index:
index
,
child:
Text
(
'item
${items[index]}
'
),
),
);
},
onReorder:
handleReorder
,
)
],
),
),
),
);
// Start gesture on first item
final
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'item 0'
)));
await
tester
.
pump
(
kPressTimeout
);
// Drag a little bit to make `ImmediateMultiDragGestureRecognizer` compete with `VerticalDragGestureRecognizer`
await
drag
.
moveBy
(
const
Offset
(
0
,
10
));
await
tester
.
pump
();
// Drag enough to move down the first item
await
drag
.
moveBy
(
const
Offset
(
0
,
40
));
await
tester
.
pump
();
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
onReorderCallCount
,
1
);
expect
(
items
,
orderedEquals
(<
int
>[
1
,
0
,
2
,
3
,
4
]));
});
// Regression test for https://github.com/flutter/flutter/issues/100451
testWidgets
(
'SliverReorderableList.builder respects findChildIndexCallback'
,
(
WidgetTester
tester
)
async
{
bool
finderCalled
=
false
;
...
...
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