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
58409c19
Unverified
Commit
58409c19
authored
Nov 08, 2021
by
xubaolin
Committed by
GitHub
Nov 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not crash when dragging ReorderableListView with two fingers simultaneously (#88508)
parent
d6dd2fa7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
0 deletions
+54
-0
reorderable_list.dart
packages/flutter/lib/src/widgets/reorderable_list.dart
+7
-0
reorderable_list_test.dart
packages/flutter/test/widgets/reorderable_list_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/reorderable_list.dart
View file @
58409c19
...
...
@@ -522,6 +522,7 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
int
?
_insertIndex
;
Offset
?
_finalDropPosition
;
MultiDragGestureRecognizer
?
_recognizer
;
int
?
_recognizerPointer
;
bool
_autoScrolling
=
false
;
// To implement the gap for the dragged item, we replace the dragged item
// with a zero sized box, and then translate all of the later items down
...
...
@@ -579,12 +580,18 @@ class SliverReorderableListState extends State<SliverReorderableList> with Ticke
setState
(()
{
if
(
_dragInfo
!=
null
)
{
cancelReorder
();
}
else
if
(
_recognizer
!=
null
&&
_recognizerPointer
!=
event
.
pointer
)
{
_recognizer
!.
dispose
();
_recognizer
=
null
;
_recognizerPointer
=
null
;
}
if
(
_items
.
containsKey
(
index
))
{
_dragIndex
=
index
;
_recognizer
=
recognizer
..
onStart
=
_dragStart
..
addPointer
(
event
);
_recognizerPointer
=
event
.
pointer
;
}
else
{
// TODO(darrenaustin): Can we handle this better, maybe scroll to the item?
throw
Exception
(
'Attempting to start a drag on a non-visible item'
);
...
...
packages/flutter/test/widgets/reorderable_list_test.dart
View file @
58409c19
...
...
@@ -7,6 +7,53 @@ import 'package:flutter/material.dart';
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
// Regression test for https://github.com/flutter/flutter/issues/88191
testWidgets
(
'Do not crash when dragging with two fingers simultaneously'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
items
=
List
<
int
>.
generate
(
3
,
(
int
index
)
=>
index
);
void
handleReorder
(
int
fromIndex
,
int
toIndex
)
{
if
(
toIndex
>
fromIndex
)
{
toIndex
-=
1
;
}
items
.
insert
(
toIndex
,
items
.
removeAt
(
fromIndex
));
}
await
tester
.
pumpWidget
(
MaterialApp
(
home:
ReorderableList
(
itemBuilder:
(
BuildContext
context
,
int
index
)
{
return
ReorderableDragStartListener
(
index:
index
,
key:
ValueKey
<
int
>(
items
[
index
]),
child:
SizedBox
(
height:
100
,
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Text
(
'item
${items[index]}
'
),
],
),
),
);
},
itemCount:
items
.
length
,
onReorder:
handleReorder
,
),
));
final
TestGesture
drag1
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'item 0'
)));
final
TestGesture
drag2
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
text
(
'item 0'
)));
await
tester
.
pump
(
kLongPressTimeout
);
await
drag1
.
moveBy
(
const
Offset
(
0
,
100
));
await
drag2
.
moveBy
(
const
Offset
(
0
,
100
));
await
tester
.
pumpAndSettle
();
await
drag1
.
up
();
await
drag2
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
tester
.
takeException
(),
isNull
);
});
testWidgets
(
'negative itemCount should assert'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
items
=
<
int
>[
1
,
2
,
3
];
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
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