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
d61f7809
Commit
d61f7809
authored
Apr 01, 2016
by
Andrew Wilson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3012 from apwilson/leave
Leave all entered targets when finishing.
parents
d8155347
f516dbcc
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
293 additions
and
320 deletions
+293
-320
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+17
-15
draggable_test.dart
packages/flutter/test/widget/draggable_test.dart
+276
-305
No files found.
packages/flutter/lib/src/widgets/drag_target.dart
View file @
d61f7809
...
...
@@ -391,7 +391,7 @@ class _DragAvatar<T> extends Drag {
final
_OnDragEnd
onDragEnd
;
_DragTargetState
<
T
>
_activeTarget
;
List
<
_DragTargetState
<
T
>>
_
last
Targets
=
<
_DragTargetState
<
T
>>[];
List
<
_DragTargetState
<
T
>>
_
entered
Targets
=
<
_DragTargetState
<
T
>>[];
Point
_position
;
Offset
_lastOffset
;
OverlayEntry
_entry
;
...
...
@@ -422,12 +422,12 @@ class _DragAvatar<T> extends Drag {
List
<
_DragTargetState
<
T
>>
targets
=
_getDragTargets
(
result
.
path
).
toList
();
bool
listsMatch
=
false
;
if
(
targets
.
length
>=
_
lastTargets
.
length
&&
_last
Targets
.
isNotEmpty
)
{
if
(
targets
.
length
>=
_
enteredTargets
.
length
&&
_entered
Targets
.
isNotEmpty
)
{
listsMatch
=
true
;
Iterator
<
_DragTargetState
<
T
>>
iterator
=
targets
.
iterator
;
for
(
int
i
=
0
;
i
<
_
last
Targets
.
length
;
i
+=
1
)
{
for
(
int
i
=
0
;
i
<
_
entered
Targets
.
length
;
i
+=
1
)
{
iterator
.
moveNext
();
if
(
iterator
.
current
!=
_
last
Targets
[
i
])
{
if
(
iterator
.
current
!=
_
entered
Targets
[
i
])
{
listsMatch
=
false
;
break
;
}
...
...
@@ -439,13 +439,11 @@ class _DragAvatar<T> extends Drag {
return
;
// Leave old targets.
for
(
int
i
=
0
;
i
<
_lastTargets
.
length
;
i
+=
1
)
_lastTargets
[
i
].
didLeave
(
data
);
_lastTargets
.
clear
();
_leaveAllEntered
();
// Enter new targets.
_DragTargetState
<
T
>
newTarget
=
targets
.
firstWhere
((
_DragTargetState
<
T
>
target
)
{
_
last
Targets
.
add
(
target
);
_
entered
Targets
.
add
(
target
);
return
target
.
didEnter
(
data
);
},
orElse:
()
=>
null
...
...
@@ -466,16 +464,20 @@ class _DragAvatar<T> extends Drag {
}
}
void
_leaveAllEntered
()
{
for
(
int
i
=
0
;
i
<
_enteredTargets
.
length
;
i
+=
1
)
_enteredTargets
[
i
].
didLeave
(
data
);
_enteredTargets
.
clear
();
}
void
finish
(
_DragEndKind
endKind
,
[
Velocity
velocity
])
{
bool
wasAccepted
=
false
;
if
(
_activeTarget
!=
null
)
{
if
(
endKind
==
_DragEndKind
.
dropped
&&
_activeTarget
!=
null
)
{
_activeTarget
.
didDrop
(
data
);
wasAccepted
=
true
;
}
else
{
_activeTarget
.
didLeave
(
data
);
}
if
(
endKind
==
_DragEndKind
.
dropped
&&
_activeTarget
!=
null
)
{
_activeTarget
.
didDrop
(
data
);
wasAccepted
=
true
;
_enteredTargets
.
remove
(
_activeTarget
);
}
_leaveAllEntered
();
_activeTarget
=
null
;
_entry
.
remove
();
_entry
=
null
;
...
...
packages/flutter/test/widget/draggable_test.dart
View file @
d61f7809
This diff is collapsed.
Click to expand it.
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