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
27eee14c
Unverified
Commit
27eee14c
authored
May 01, 2020
by
Daniel Iglesia
Committed by
GitHub
May 01, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DragTarget callback onAcceptDetails, plus helper class DragTarget… (#55257)
parent
6a75dc44
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
209 additions
and
22 deletions
+209
-22
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+33
-2
draggable_test.dart
packages/flutter/test/widgets/draggable_test.dart
+176
-20
No files found.
packages/flutter/lib/src/widgets/drag_target.dart
View file @
27eee14c
...
...
@@ -21,6 +21,11 @@ typedef DragTargetWillAccept<T> = bool Function(T data);
/// Used by [DragTarget.onAccept].
typedef
DragTargetAccept
<
T
>
=
void
Function
(
T
data
);
/// Signature for determining information about the acceptance by a [DragTarget].
///
/// Used by [DragTarget.onAcceptWithDetails].
typedef
DragTargetAcceptWithDetails
<
T
>
=
void
Function
(
DragTargetDetails
<
T
>
details
);
/// Signature for building children of a [DragTarget].
///
/// The `candidateData` argument contains the list of drag data that is hovering
...
...
@@ -459,6 +464,21 @@ class DraggableDetails {
final
Offset
offset
;
}
/// Represents the details when a pointer event occurred on the [DragTarget].
class
DragTargetDetails
<
T
>
{
/// Creates details for a [DragTarget] callback.
///
/// The [offset] must not be null.
DragTargetDetails
({
@required
this
.
data
,
@required
this
.
offset
})
:
assert
(
offset
!=
null
);
/// The data that was dropped onto this [DragTarget].
final
T
data
;
/// The global position when the specific pointer event occurred on
/// the draggable.
final
Offset
offset
;
}
/// A widget that receives data when a [Draggable] widget is dropped.
///
/// When a draggable is dragged on top of a drag target, the drag target is
...
...
@@ -480,6 +500,7 @@ class DragTarget<T> extends StatefulWidget {
@required
this
.
builder
,
this
.
onWillAccept
,
this
.
onAccept
,
this
.
onAcceptWithDetails
,
this
.
onLeave
,
})
:
super
(
key:
key
);
...
...
@@ -493,13 +514,21 @@ class DragTarget<T> extends StatefulWidget {
/// piece of data being dragged over this drag target.
///
/// Called when a piece of data enters the target. This will be followed by
/// either [onAccept]
, if the data is dropped, or [onLeave], if the drag
/// leaves the target.
/// either [onAccept]
and [onAcceptWithDetails], if the data is dropped, or
///
[onLeave], if the drag
leaves the target.
final
DragTargetWillAccept
<
T
>
onWillAccept
;
/// Called when an acceptable piece of data was dropped over this drag target.
///
/// Equivalent to [onAcceptWithDetails], but only includes the data.
final
DragTargetAccept
<
T
>
onAccept
;
/// Called when an acceptable piece of data was dropped over this drag target.
///
/// Equivalent to [onAccept], but with information, including the data, in a
/// [DragTargetDetails].
final
DragTargetAcceptWithDetails
<
T
>
onAcceptWithDetails
;
/// Called when a given piece of data being dragged over this target leaves
/// the target.
final
DragTargetLeave
onLeave
;
...
...
@@ -553,6 +582,8 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
});
if
(
widget
.
onAccept
!=
null
)
widget
.
onAccept
(
avatar
.
data
as
T
);
if
(
widget
.
onAcceptWithDetails
!=
null
)
widget
.
onAcceptWithDetails
(
DragTargetDetails
<
T
>(
data:
avatar
.
data
as
T
,
offset:
avatar
.
_lastOffset
));
}
@override
...
...
packages/flutter/test/widgets/draggable_test.dart
View file @
27eee14c
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