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
f8eee10f
Unverified
Commit
f8eee10f
authored
Mar 02, 2022
by
Kate Lovett
Committed by
GitHub
Mar 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Draggable can be accepted when the data is null" (#99419)
parent
4b20ce74
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
130 deletions
+37
-130
drag_and_drop.dart
dev/manual_tests/lib/drag_and_drop.dart
+3
-3
draggable.0.dart
examples/api/lib/widgets/drag_target/draggable.0.dart
+2
-2
drag_target.dart
packages/flutter/lib/src/widgets/drag_target.dart
+5
-5
draggable_test.dart
packages/flutter/test/widgets/draggable_test.dart
+27
-120
No files found.
dev/manual_tests/lib/drag_and_drop.dart
View file @
f8eee10f
...
...
@@ -16,9 +16,9 @@ class ExampleDragTarget extends StatefulWidget {
class
ExampleDragTargetState
extends
State
<
ExampleDragTarget
>
{
Color
_color
=
Colors
.
grey
;
void
_handleAccept
(
Color
?
data
)
{
void
_handleAccept
(
Color
data
)
{
setState
(()
{
_color
=
data
!
;
_color
=
data
;
});
}
...
...
@@ -215,7 +215,7 @@ class MovableBall extends StatelessWidget {
);
}
else
{
return
DragTarget
<
bool
>(
onAccept:
(
bool
?
data
)
{
callback
(
position
);
},
onAccept:
(
bool
data
)
{
callback
(
position
);
},
builder:
(
BuildContext
context
,
List
<
bool
?>
accepted
,
List
<
dynamic
>
rejected
)
{
return
dashedBall
;
},
...
...
examples/api/lib/widgets/drag_target/draggable.0.dart
View file @
f8eee10f
...
...
@@ -81,9 +81,9 @@ class _MyStatefulWidgetState extends State<MyStatefulWidget> {
),
);
},
onAccept:
(
int
?
data
)
{
onAccept:
(
int
data
)
{
setState
(()
{
acceptedData
+=
data
!
;
acceptedData
+=
data
;
});
},
),
...
...
packages/flutter/lib/src/widgets/drag_target.dart
View file @
f8eee10f
...
...
@@ -20,7 +20,7 @@ typedef DragTargetWillAccept<T> = bool Function(T? data);
/// Signature for causing a [DragTarget] to accept the given data.
///
/// Used by [DragTarget.onAccept].
typedef
DragTargetAccept
<
T
>
=
void
Function
(
T
?
data
);
typedef
DragTargetAccept
<
T
>
=
void
Function
(
T
data
);
/// Signature for determining information about the acceptance by a [DragTarget].
///
...
...
@@ -638,7 +638,7 @@ class DragTargetDetails<T> {
DragTargetDetails
({
required
this
.
data
,
required
this
.
offset
})
:
assert
(
offset
!=
null
);
/// The data that was dropped onto this [DragTarget].
final
T
?
data
;
final
T
data
;
/// The global position when the specific pointer event occurred on
/// the draggable.
...
...
@@ -767,14 +767,14 @@ class _DragTargetState<T extends Object> extends State<DragTarget<T>> {
setState
(()
{
_candidateAvatars
.
remove
(
avatar
);
});
widget
.
onAccept
?.
call
(
avatar
.
data
as
T
?
);
widget
.
onAcceptWithDetails
?.
call
(
DragTargetDetails
<
T
>(
data:
avatar
.
data
as
T
?
,
offset:
avatar
.
_lastOffset
!));
widget
.
onAccept
?.
call
(
avatar
.
data
!
as
T
);
widget
.
onAcceptWithDetails
?.
call
(
DragTargetDetails
<
T
>(
data:
avatar
.
data
!
as
T
,
offset:
avatar
.
_lastOffset
!));
}
void
didMove
(
_DragAvatar
<
Object
>
avatar
)
{
if
(!
mounted
)
return
;
widget
.
onMove
?.
call
(
DragTargetDetails
<
T
>(
data:
avatar
.
data
as
T
?
,
offset:
avatar
.
_lastOffset
!));
widget
.
onMove
?.
call
(
DragTargetDetails
<
T
>(
data:
avatar
.
data
!
as
T
,
offset:
avatar
.
_lastOffset
!));
}
@override
...
...
packages/flutter/test/widgets/draggable_test.dart
View file @
f8eee10f
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