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
Show 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);
...
@@ -21,6 +21,11 @@ typedef DragTargetWillAccept<T> = bool Function(T data);
/// Used by [DragTarget.onAccept].
/// 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].
///
/// Used by [DragTarget.onAcceptWithDetails].
typedef
DragTargetAcceptWithDetails
<
T
>
=
void
Function
(
DragTargetDetails
<
T
>
details
);
/// Signature for building children of a [DragTarget].
/// Signature for building children of a [DragTarget].
///
///
/// The `candidateData` argument contains the list of drag data that is hovering
/// The `candidateData` argument contains the list of drag data that is hovering
...
@@ -459,6 +464,21 @@ class DraggableDetails {
...
@@ -459,6 +464,21 @@ class DraggableDetails {
final
Offset
offset
;
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.
/// 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
/// When a draggable is dragged on top of a drag target, the drag target is
...
@@ -480,6 +500,7 @@ class DragTarget<T> extends StatefulWidget {
...
@@ -480,6 +500,7 @@ class DragTarget<T> extends StatefulWidget {
@required
this
.
builder
,
@required
this
.
builder
,
this
.
onWillAccept
,
this
.
onWillAccept
,
this
.
onAccept
,
this
.
onAccept
,
this
.
onAcceptWithDetails
,
this
.
onLeave
,
this
.
onLeave
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
...
@@ -493,13 +514,21 @@ class DragTarget<T> extends StatefulWidget {
...
@@ -493,13 +514,21 @@ class DragTarget<T> extends StatefulWidget {
/// piece of data being dragged over this drag target.
/// piece of data being dragged over this drag target.
///
///
/// Called when a piece of data enters the target. This will be followed by
/// 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
/// either [onAccept]
and [onAcceptWithDetails], if the data is dropped, or
/// leaves the target.
///
[onLeave], if the drag
leaves the target.
final
DragTargetWillAccept
<
T
>
onWillAccept
;
final
DragTargetWillAccept
<
T
>
onWillAccept
;
/// Called when an acceptable piece of data was dropped over this drag target.
/// 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
;
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
/// Called when a given piece of data being dragged over this target leaves
/// the target.
/// the target.
final
DragTargetLeave
onLeave
;
final
DragTargetLeave
onLeave
;
...
@@ -553,6 +582,8 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
...
@@ -553,6 +582,8 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
});
});
if
(
widget
.
onAccept
!=
null
)
if
(
widget
.
onAccept
!=
null
)
widget
.
onAccept
(
avatar
.
data
as
T
);
widget
.
onAccept
(
avatar
.
data
as
T
);
if
(
widget
.
onAcceptWithDetails
!=
null
)
widget
.
onAcceptWithDetails
(
DragTargetDetails
<
T
>(
data:
avatar
.
data
as
T
,
offset:
avatar
.
_lastOffset
));
}
}
@override
@override
...
...
packages/flutter/test/widgets/draggable_test.dart
View file @
27eee14c
...
@@ -13,6 +13,7 @@ import 'semantics_tester.dart';
...
@@ -13,6 +13,7 @@ import 'semantics_tester.dart';
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Drag and drop - control test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - control test'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
int
dragStartedCount
=
0
;
int
dragStartedCount
=
0
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -31,12 +32,14 @@ void main() {
...
@@ -31,12 +32,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -47,6 +50,7 @@ void main() {
...
@@ -47,6 +50,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -57,6 +61,7 @@ void main() {
...
@@ -57,6 +61,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -66,6 +71,8 @@ void main() {
...
@@ -66,6 +71,8 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -179,6 +186,9 @@ void main() {
...
@@ -179,6 +186,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
events
.
add
(
'drop'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
],
],
),
),
...
@@ -217,7 +227,7 @@ void main() {
...
@@ -217,7 +227,7 @@ void main() {
expect
(
events
,
isEmpty
);
expect
(
events
,
isEmpty
);
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop'
]));
expect
(
events
,
equals
(<
String
>[
'drop'
,
'details'
]));
events
.
clear
();
events
.
clear
();
// drag and tap and drop
// drag and tap and drop
...
@@ -235,7 +245,7 @@ void main() {
...
@@ -235,7 +245,7 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'Target'
));
await
tester
.
tap
(
find
.
text
(
'Target'
));
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'tap'
,
'tap'
,
'drop'
]));
expect
(
events
,
equals
(<
String
>[
'tap'
,
'tap'
,
'drop'
,
'details'
]));
events
.
clear
();
events
.
clear
();
});
});
...
@@ -264,6 +274,9 @@ void main() {
...
@@ -264,6 +274,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
events
.
add
(
'drop'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
],
],
),
),
...
@@ -289,7 +302,7 @@ void main() {
...
@@ -289,7 +302,7 @@ void main() {
expect
(
events
,
isEmpty
);
expect
(
events
,
isEmpty
);
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop'
]));
expect
(
events
,
equals
(<
String
>[
'drop'
,
'details'
]));
events
.
clear
();
events
.
clear
();
});
});
...
@@ -312,6 +325,9 @@ void main() {
...
@@ -312,6 +325,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
events
.
add
(
'drop'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
],
],
),
),
...
@@ -358,6 +374,9 @@ void main() {
...
@@ -358,6 +374,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
events
.
add
(
'drop'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
],
],
),
),
...
@@ -384,7 +403,7 @@ void main() {
...
@@ -384,7 +403,7 @@ void main() {
expect
(
events
,
isEmpty
);
expect
(
events
,
isEmpty
);
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop'
]));
expect
(
events
,
equals
(<
String
>[
'drop'
,
'details'
]));
});
});
testWidgets
(
'Drag and drop - horizontal and vertical draggables in vertical block'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - horizontal and vertical draggables in vertical block'
,
(
WidgetTester
tester
)
async
{
...
@@ -402,6 +421,9 @@ void main() {
...
@@ -402,6 +421,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop
$data
'
);
events
.
add
(
'drop
$data
'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
Container
(
height:
400.0
),
Container
(
height:
400.0
),
const
Draggable
<
int
>(
const
Draggable
<
int
>(
...
@@ -439,7 +461,7 @@ void main() {
...
@@ -439,7 +461,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop 2'
]));
expect
(
events
,
equals
(<
String
>[
'drop 2'
,
'details'
]));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dy
,
greaterThan
(
0.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dy
,
greaterThan
(
0.0
));
events
.
clear
();
events
.
clear
();
...
@@ -456,7 +478,7 @@ void main() {
...
@@ -456,7 +478,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop 1'
]));
expect
(
events
,
equals
(<
String
>[
'drop 1'
,
'details'
]));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dy
,
greaterThan
(
0.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dy
,
greaterThan
(
0.0
));
events
.
clear
();
events
.
clear
();
...
@@ -474,7 +496,7 @@ void main() {
...
@@ -474,7 +496,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop 2'
]));
expect
(
events
,
equals
(<
String
>[
'drop 2'
,
'details'
]));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dy
,
greaterThan
(
0.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dy
,
greaterThan
(
0.0
));
events
.
clear
();
events
.
clear
();
...
@@ -510,6 +532,9 @@ void main() {
...
@@ -510,6 +532,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop
$data
'
);
events
.
add
(
'drop
$data
'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
Container
(
width:
400.0
),
Container
(
width:
400.0
),
const
Draggable
<
int
>(
const
Draggable
<
int
>(
...
@@ -547,7 +572,7 @@ void main() {
...
@@ -547,7 +572,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop 1'
]));
expect
(
events
,
equals
(<
String
>[
'drop 1'
,
'details'
]));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dx
,
greaterThan
(
0.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dx
,
greaterThan
(
0.0
));
events
.
clear
();
events
.
clear
();
...
@@ -564,7 +589,7 @@ void main() {
...
@@ -564,7 +589,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop 2'
]));
expect
(
events
,
equals
(<
String
>[
'drop 2'
,
'details'
]));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dx
,
greaterThan
(
0.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dx
,
greaterThan
(
0.0
));
events
.
clear
();
events
.
clear
();
...
@@ -582,7 +607,7 @@ void main() {
...
@@ -582,7 +607,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
events
,
equals
(<
String
>[
'drop 1'
]));
expect
(
events
,
equals
(<
String
>[
'drop 1'
,
'details'
]));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dx
,
greaterThan
(
0.0
));
expect
(
tester
.
getCenter
(
find
.
text
(
'Target'
)).
dx
,
greaterThan
(
0.0
));
events
.
clear
();
events
.
clear
();
...
@@ -617,6 +642,9 @@ void main() {
...
@@ -617,6 +642,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop
$data
'
);
events
.
add
(
'drop
$data
'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
Container
(
width:
400.0
),
Container
(
width:
400.0
),
const
Draggable
<
int
>(
const
Draggable
<
int
>(
...
@@ -732,6 +760,7 @@ void main() {
...
@@ -732,6 +760,7 @@ void main() {
testWidgets
(
'Drag and drop - onDraggableCanceled not called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDraggableCanceled not called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDraggableCanceledCalled
=
false
;
bool
onDraggableCanceledCalled
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -750,12 +779,14 @@ void main() {
...
@@ -750,12 +779,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -766,6 +797,7 @@ void main() {
...
@@ -766,6 +797,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -776,6 +808,7 @@ void main() {
...
@@ -776,6 +808,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -785,6 +818,8 @@ void main() {
...
@@ -785,6 +818,8 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -793,6 +828,7 @@ void main() {
...
@@ -793,6 +828,7 @@ void main() {
testWidgets
(
'Drag and drop - onDraggableCanceled called if dropped on non-accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDraggableCanceled called if dropped on non-accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDraggableCanceledCalled
=
false
;
bool
onDraggableCanceledCalled
=
false
;
Velocity
onDraggableCanceledVelocity
;
Velocity
onDraggableCanceledVelocity
;
Offset
onDraggableCanceledOffset
;
Offset
onDraggableCanceledOffset
;
...
@@ -818,12 +854,15 @@ void main() {
...
@@ -818,12 +854,15 @@ void main() {
);
);
},
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -834,6 +873,7 @@ void main() {
...
@@ -834,6 +873,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -844,6 +884,7 @@ void main() {
...
@@ -844,6 +884,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -853,6 +894,7 @@ void main() {
...
@@ -853,6 +894,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -863,6 +905,7 @@ void main() {
...
@@ -863,6 +905,7 @@ void main() {
testWidgets
(
'Drag and drop - onDraggableCanceled called if dropped on non-accepting target with correct velocity'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDraggableCanceled called if dropped on non-accepting target with correct velocity'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDraggableCanceledCalled
=
false
;
bool
onDraggableCanceledCalled
=
false
;
Velocity
onDraggableCanceledVelocity
;
Velocity
onDraggableCanceledVelocity
;
Offset
onDraggableCanceledOffset
;
Offset
onDraggableCanceledOffset
;
...
@@ -886,12 +929,15 @@ void main() {
...
@@ -886,12 +929,15 @@ void main() {
child:
const
Text
(
'Target'
),
child:
const
Text
(
'Target'
),
);
);
},
},
onWillAccept:
(
int
data
)
=>
false
),
onWillAccept:
(
int
data
)
=>
false
,
],
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
));
],
)));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -902,6 +948,7 @@ void main() {
...
@@ -902,6 +948,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -913,6 +960,7 @@ void main() {
...
@@ -913,6 +960,7 @@ void main() {
testWidgets
(
'Drag and drop - onDragEnd not called if dropped on non-accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDragEnd not called if dropped on non-accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragEndCalled
=
false
;
bool
onDragEndCalled
=
false
;
DraggableDetails
onDragEndDraggableDetails
;
DraggableDetails
onDragEndDraggableDetails
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -935,12 +983,15 @@ void main() {
...
@@ -935,12 +983,15 @@ void main() {
);
);
},
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -951,6 +1002,7 @@ void main() {
...
@@ -951,6 +1002,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -961,6 +1013,7 @@ void main() {
...
@@ -961,6 +1013,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -970,6 +1023,7 @@ void main() {
...
@@ -970,6 +1023,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1120,6 +1174,7 @@ void main() {
...
@@ -1120,6 +1174,7 @@ void main() {
testWidgets
(
'Drag and drop - onDragCompleted not called if dropped on non-accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDragCompleted not called if dropped on non-accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragCompletedCalled
=
false
;
bool
onDragCompletedCalled
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -1141,12 +1196,15 @@ void main() {
...
@@ -1141,12 +1196,15 @@ void main() {
);
);
},
},
onWillAccept:
(
int
data
)
=>
false
,
onWillAccept:
(
int
data
)
=>
false
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1157,6 +1215,7 @@ void main() {
...
@@ -1157,6 +1215,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1167,6 +1226,7 @@ void main() {
...
@@ -1167,6 +1226,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1176,6 +1236,7 @@ void main() {
...
@@ -1176,6 +1236,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1184,6 +1245,7 @@ void main() {
...
@@ -1184,6 +1245,7 @@ void main() {
testWidgets
(
'Drag and drop - onDragEnd called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDragEnd called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragEndCalled
=
false
;
bool
onDragEndCalled
=
false
;
DraggableDetails
onDragEndDraggableDetails
;
DraggableDetails
onDragEndDraggableDetails
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -1203,12 +1265,14 @@ void main() {
...
@@ -1203,12 +1265,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1219,6 +1283,7 @@ void main() {
...
@@ -1219,6 +1283,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1229,6 +1294,7 @@ void main() {
...
@@ -1229,6 +1294,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1238,7 +1304,11 @@ void main() {
...
@@ -1238,7 +1304,11 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
final
Offset
droppedLocation
=
tester
.
getTopLeft
(
find
.
text
(
'Target'
));
final
Offset
droppedLocation
=
tester
.
getTopLeft
(
find
.
text
(
'Target'
));
final
Offset
expectedDropOffset
=
Offset
(
droppedLocation
.
dx
,
secondLocation
.
dy
-
firstLocation
.
dy
);
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1246,9 +1316,7 @@ void main() {
...
@@ -1246,9 +1316,7 @@ void main() {
expect
(
onDragEndDraggableDetails
,
isNotNull
);
expect
(
onDragEndDraggableDetails
,
isNotNull
);
expect
(
onDragEndDraggableDetails
.
wasAccepted
,
isTrue
);
expect
(
onDragEndDraggableDetails
.
wasAccepted
,
isTrue
);
expect
(
onDragEndDraggableDetails
.
velocity
,
equals
(
Velocity
.
zero
));
expect
(
onDragEndDraggableDetails
.
velocity
,
equals
(
Velocity
.
zero
));
expect
(
onDragEndDraggableDetails
.
offset
,
expect
(
onDragEndDraggableDetails
.
offset
,
equals
(
expectedDropOffset
));
equals
(
Offset
(
droppedLocation
.
dx
,
secondLocation
.
dy
-
firstLocation
.
dy
)));
});
});
testWidgets
(
'DragTarget does not call onDragEnd when remove from the tree'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'DragTarget does not call onDragEnd when remove from the tree'
,
(
WidgetTester
tester
)
async
{
...
@@ -1273,6 +1341,9 @@ void main() {
...
@@ -1273,6 +1341,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
events
.
add
(
'drop'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
],
],
),
),
...
@@ -1316,6 +1387,7 @@ void main() {
...
@@ -1316,6 +1387,7 @@ void main() {
testWidgets
(
'Drag and drop - onDragCompleted called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - onDragCompleted called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragCompletedCalled
=
false
;
bool
onDragCompletedCalled
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -1334,12 +1406,14 @@ void main() {
...
@@ -1334,12 +1406,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1350,6 +1424,7 @@ void main() {
...
@@ -1350,6 +1424,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1360,6 +1435,7 @@ void main() {
...
@@ -1360,6 +1435,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1369,6 +1445,8 @@ void main() {
...
@@ -1369,6 +1445,8 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1377,7 +1455,9 @@ void main() {
...
@@ -1377,7 +1455,9 @@ void main() {
testWidgets
(
'Drag and drop - allow pass thru of unaccepted data test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - allow pass thru of unaccepted data test'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
acceptedInts
=
<
int
>[];
final
List
<
int
>
acceptedInts
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedIntsDetails
=
<
DragTargetDetails
<
int
>>[];
final
List
<
double
>
acceptedDoubles
=
<
double
>[];
final
List
<
double
>
acceptedDoubles
=
<
double
>[];
final
List
<
DragTargetDetails
<
double
>>
acceptedDoublesDetails
=
<
DragTargetDetails
<
double
>>[];
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
home:
Column
(
...
@@ -1404,6 +1484,7 @@ void main() {
...
@@ -1404,6 +1484,7 @@ void main() {
);
);
},
},
onAccept:
acceptedInts
.
add
,
onAccept:
acceptedInts
.
add
,
onAcceptWithDetails:
acceptedIntsDetails
.
add
,
),
),
DragTarget
<
double
>(
DragTarget
<
double
>(
builder:
(
BuildContext
context
,
List
<
double
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
double
>
data
,
List
<
dynamic
>
rejects
)
{
...
@@ -1415,6 +1496,7 @@ void main() {
...
@@ -1415,6 +1496,7 @@ void main() {
);
);
},
},
onAccept:
acceptedDoubles
.
add
,
onAccept:
acceptedDoubles
.
add
,
onAcceptWithDetails:
acceptedDoublesDetails
.
add
,
),
),
],
],
),
),
...
@@ -1423,7 +1505,9 @@ void main() {
...
@@ -1423,7 +1505,9 @@ void main() {
));
));
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedIntsDetails
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoublesDetails
,
isEmpty
);
expect
(
find
.
text
(
'IntSource'
),
findsOneWidget
);
expect
(
find
.
text
(
'IntSource'
),
findsOneWidget
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleSource'
),
findsOneWidget
);
expect
(
find
.
text
(
'DoubleSource'
),
findsOneWidget
);
...
@@ -1440,7 +1524,9 @@ void main() {
...
@@ -1440,7 +1524,9 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedIntsDetails
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoublesDetails
,
isEmpty
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsOneWidget
);
...
@@ -1448,7 +1534,9 @@ void main() {
...
@@ -1448,7 +1534,9 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedIntsDetails
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoublesDetails
,
isEmpty
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsOneWidget
);
...
@@ -1456,18 +1544,24 @@ void main() {
...
@@ -1456,18 +1544,24 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedIntsDetails
,
isEmpty
);
expect
(
acceptedDoubles
,
equals
(<
double
>[
1.0
]));
expect
(
acceptedDoubles
,
equals
(<
double
>[
1.0
]));
expect
(
acceptedDoublesDetails
,
hasLength
(
1
));
expect
(
acceptedDoublesDetails
.
first
.
offset
,
const
Offset
(
112.0
,
122.0
));
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
acceptedDoubles
.
clear
();
acceptedDoubles
.
clear
();
acceptedDoublesDetails
.
clear
();
// Drag the int draggable.
// Drag the int draggable.
final
TestGesture
intGesture
=
await
tester
.
startGesture
(
intLocation
,
pointer:
7
);
final
TestGesture
intGesture
=
await
tester
.
startGesture
(
intLocation
,
pointer:
7
);
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedIntsDetails
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoublesDetails
,
isEmpty
);
expect
(
find
.
text
(
'IntDragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'IntDragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
...
@@ -1475,7 +1569,9 @@ void main() {
...
@@ -1475,7 +1569,9 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedInts
,
isEmpty
);
expect
(
acceptedIntsDetails
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoublesDetails
,
isEmpty
);
expect
(
find
.
text
(
'IntDragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'IntDragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
...
@@ -1483,14 +1579,19 @@ void main() {
...
@@ -1483,14 +1579,19 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedInts
,
equals
(<
int
>[
1
]));
expect
(
acceptedInts
,
equals
(<
int
>[
1
]));
expect
(
acceptedIntsDetails
,
hasLength
(
1
));
expect
(
acceptedIntsDetails
.
first
.
offset
,
const
Offset
(
184.0
,
122.0
));
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoubles
,
isEmpty
);
expect
(
acceptedDoublesDetails
,
isEmpty
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'IntDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
expect
(
find
.
text
(
'DoubleDragging'
),
findsNothing
);
});
});
testWidgets
(
'Drag and drop - allow pass thru of unaccepted data twice test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - allow pass thru of unaccepted data twice test'
,
(
WidgetTester
tester
)
async
{
final
List
<
DragTargetData
>
acceptedDragTargetDatas
=
<
DragTargetData
>[];
final
List
<
DragTargetData
>
acceptedDragTargetDatas
=
<
DragTargetData
>[];
final
List
<
DragTargetDetails
<
DragTargetData
>>
acceptedDragTargetDataDetails
=
<
DragTargetDetails
<
DragTargetData
>>[];
final
List
<
ExtendedDragTargetData
>
acceptedExtendedDragTargetDatas
=
<
ExtendedDragTargetData
>[];
final
List
<
ExtendedDragTargetData
>
acceptedExtendedDragTargetDatas
=
<
ExtendedDragTargetData
>[];
final
List
<
DragTargetDetails
<
ExtendedDragTargetData
>>
acceptedExtendedDragTargetDataDetails
=
<
DragTargetDetails
<
ExtendedDragTargetData
>>[];
final
DragTargetData
dragTargetData
=
DragTargetData
();
final
DragTargetData
dragTargetData
=
DragTargetData
();
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
home:
Column
(
...
@@ -1511,6 +1612,7 @@ void main() {
...
@@ -1511,6 +1612,7 @@ void main() {
),
),
);
);
},
onAccept:
acceptedDragTargetDatas
.
add
,
},
onAccept:
acceptedDragTargetDatas
.
add
,
onAcceptWithDetails:
acceptedDragTargetDataDetails
.
add
,
),
),
DragTarget
<
ExtendedDragTargetData
>(
DragTarget
<
ExtendedDragTargetData
>(
builder:
(
BuildContext
context
,
List
<
ExtendedDragTargetData
>
data
,
List
<
dynamic
>
rejects
)
{
builder:
(
BuildContext
context
,
List
<
ExtendedDragTargetData
>
data
,
List
<
dynamic
>
rejects
)
{
...
@@ -1522,6 +1624,7 @@ void main() {
...
@@ -1522,6 +1624,7 @@ void main() {
);
);
},
},
onAccept:
acceptedExtendedDragTargetDatas
.
add
,
onAccept:
acceptedExtendedDragTargetDatas
.
add
,
onAcceptWithDetails:
acceptedExtendedDragTargetDataDetails
.
add
,
),
),
],
],
),
),
...
@@ -1541,15 +1644,20 @@ void main() {
...
@@ -1541,15 +1644,20 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
acceptedDragTargetDatas
,
equals
(<
DragTargetData
>[
dragTargetData
]));
expect
(
acceptedDragTargetDatas
,
equals
(<
DragTargetData
>[
dragTargetData
]));
expect
(
acceptedDragTargetDataDetails
,
hasLength
(
1
));
expect
(
acceptedDragTargetDataDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
acceptedExtendedDragTargetDatas
,
isEmpty
);
expect
(
acceptedExtendedDragTargetDatas
,
isEmpty
);
expect
(
acceptedExtendedDragTargetDataDetails
,
isEmpty
);
acceptedDragTargetDatas
.
clear
();
acceptedDragTargetDatas
.
clear
();
acceptedDragTargetDataDetails
.
clear
();
await
tester
.
pump
();
await
tester
.
pump
();
}
}
});
});
testWidgets
(
'Drag and drop - maxSimultaneousDrags'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - maxSimultaneousDrags'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
Widget
build
(
int
maxSimultaneousDrags
)
{
Widget
build
(
int
maxSimultaneousDrags
)
{
return
MaterialApp
(
return
MaterialApp
(
...
@@ -1566,6 +1674,7 @@ void main() {
...
@@ -1566,6 +1674,7 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
...
@@ -1578,6 +1687,7 @@ void main() {
...
@@ -1578,6 +1687,7 @@ void main() {
final
Offset
secondLocation
=
tester
.
getCenter
(
find
.
text
(
'Target'
));
final
Offset
secondLocation
=
tester
.
getCenter
(
find
.
text
(
'Target'
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1586,6 +1696,7 @@ void main() {
...
@@ -1586,6 +1696,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1595,6 +1706,7 @@ void main() {
...
@@ -1595,6 +1706,7 @@ void main() {
await
tester
.
pumpWidget
(
build
(
2
));
await
tester
.
pumpWidget
(
build
(
2
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1603,6 +1715,7 @@ void main() {
...
@@ -1603,6 +1715,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1611,6 +1724,7 @@ void main() {
...
@@ -1611,6 +1724,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNWidgets
(
2
));
expect
(
find
.
text
(
'Dragging'
),
findsNWidgets
(
2
));
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1619,6 +1733,7 @@ void main() {
...
@@ -1619,6 +1733,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNWidgets
(
2
));
expect
(
find
.
text
(
'Dragging'
),
findsNWidgets
(
2
));
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1629,6 +1744,7 @@ void main() {
...
@@ -1629,6 +1744,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNWidgets
(
2
));
expect
(
find
.
text
(
'Dragging'
),
findsNWidgets
(
2
));
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1637,6 +1753,8 @@ void main() {
...
@@ -1637,6 +1753,8 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1645,6 +1763,9 @@ void main() {
...
@@ -1645,6 +1763,9 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
,
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
,
1
]));
expect
(
acceptedDetails
,
hasLength
(
2
));
expect
(
acceptedDetails
[
0
].
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
acceptedDetails
[
1
].
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1653,6 +1774,9 @@ void main() {
...
@@ -1653,6 +1774,9 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
,
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
,
1
]));
expect
(
acceptedDetails
,
hasLength
(
2
));
expect
(
acceptedDetails
[
0
].
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
acceptedDetails
[
1
].
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1749,6 +1873,9 @@ void main() {
...
@@ -1749,6 +1873,9 @@ void main() {
onAccept:
(
int
data
)
{
onAccept:
(
int
data
)
{
events
.
add
(
'drop'
);
events
.
add
(
'drop'
);
},
},
onAcceptWithDetails:
(
DragTargetDetails
<
int
>
_
)
{
events
.
add
(
'details'
);
},
),
),
],
],
),
),
...
@@ -1791,6 +1918,7 @@ void main() {
...
@@ -1791,6 +1918,7 @@ void main() {
testWidgets
(
'Drag and drop - remove draggable'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Drag and drop - remove draggable'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Column
(
home:
Column
(
...
@@ -1805,12 +1933,14 @@ void main() {
...
@@ -1805,12 +1933,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1820,6 +1950,7 @@ void main() {
...
@@ -1820,6 +1950,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1832,12 +1963,14 @@ void main() {
...
@@ -1832,12 +1963,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsNothing
);
expect
(
find
.
text
(
'Source'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1847,6 +1980,7 @@ void main() {
...
@@ -1847,6 +1980,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsNothing
);
expect
(
find
.
text
(
'Source'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1855,6 +1989,8 @@ void main() {
...
@@ -1855,6 +1989,8 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
26.0
));
expect
(
find
.
text
(
'Source'
),
findsNothing
);
expect
(
find
.
text
(
'Source'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1886,6 +2022,7 @@ void main() {
...
@@ -1886,6 +2022,7 @@ void main() {
testWidgets
(
'long-press draggable calls onDragEnd called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'long-press draggable calls onDragEnd called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragEndCalled
=
false
;
bool
onDragEndCalled
=
false
;
DraggableDetails
onDragEndDraggableDetails
;
DraggableDetails
onDragEndDraggableDetails
;
...
@@ -1906,12 +2043,14 @@ void main() {
...
@@ -1906,12 +2043,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1922,6 +2061,7 @@ void main() {
...
@@ -1922,6 +2061,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1930,6 +2070,7 @@ void main() {
...
@@ -1930,6 +2070,7 @@ void main() {
await
tester
.
pump
(
kLongPressTimeout
);
await
tester
.
pump
(
kLongPressTimeout
);
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1941,6 +2082,7 @@ void main() {
...
@@ -1941,6 +2082,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1950,7 +2092,11 @@ void main() {
...
@@ -1950,7 +2092,11 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
final
Offset
droppedLocation
=
tester
.
getTopLeft
(
find
.
text
(
'Target'
));
final
Offset
droppedLocation
=
tester
.
getTopLeft
(
find
.
text
(
'Target'
));
final
Offset
expectedDropOffset
=
Offset
(
droppedLocation
.
dx
,
secondLocation
.
dy
-
firstLocation
.
dy
);
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
,
hasLength
(
1
));
expect
(
acceptedDetails
.
first
.
offset
,
expectedDropOffset
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1958,13 +2104,12 @@ void main() {
...
@@ -1958,13 +2104,12 @@ void main() {
expect
(
onDragEndDraggableDetails
,
isNotNull
);
expect
(
onDragEndDraggableDetails
,
isNotNull
);
expect
(
onDragEndDraggableDetails
.
wasAccepted
,
isTrue
);
expect
(
onDragEndDraggableDetails
.
wasAccepted
,
isTrue
);
expect
(
onDragEndDraggableDetails
.
velocity
,
equals
(
Velocity
.
zero
));
expect
(
onDragEndDraggableDetails
.
velocity
,
equals
(
Velocity
.
zero
));
expect
(
onDragEndDraggableDetails
.
offset
,
expect
(
onDragEndDraggableDetails
.
offset
,
equals
(
expectedDropOffset
));
equals
(
Offset
(
droppedLocation
.
dx
,
secondLocation
.
dy
-
firstLocation
.
dy
)));
});
});
testWidgets
(
'long-press draggable calls onDragCompleted called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'long-press draggable calls onDragCompleted called if dropped on accepting target'
,
(
WidgetTester
tester
)
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
bool
onDragCompletedCalled
=
false
;
bool
onDragCompletedCalled
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
await
tester
.
pumpWidget
(
MaterialApp
(
...
@@ -1983,12 +2128,14 @@ void main() {
...
@@ -1983,12 +2128,14 @@ void main() {
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
));
));
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -1999,6 +2146,7 @@ void main() {
...
@@ -1999,6 +2146,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -2007,6 +2155,7 @@ void main() {
...
@@ -2007,6 +2155,7 @@ void main() {
await
tester
.
pump
(
kLongPressTimeout
);
await
tester
.
pump
(
kLongPressTimeout
);
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -2018,6 +2167,7 @@ void main() {
...
@@ -2018,6 +2167,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -2027,6 +2177,7 @@ void main() {
...
@@ -2027,6 +2177,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
accepted
,
equals
(<
int
>[
1
]));
expect
(
acceptedDetails
.
first
.
offset
,
const
Offset
(
256.0
,
74.0
));
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -2278,6 +2429,7 @@ Future<void> _testLongPressDraggableHapticFeedback({ WidgetTester tester, bool h
...
@@ -2278,6 +2429,7 @@ Future<void> _testLongPressDraggableHapticFeedback({ WidgetTester tester, bool h
Future
<
void
>
_testChildAnchorFeedbackPosition
({
WidgetTester
tester
,
double
top
=
0.0
,
double
left
=
0.0
})
async
{
Future
<
void
>
_testChildAnchorFeedbackPosition
({
WidgetTester
tester
,
double
top
=
0.0
,
double
left
=
0.0
})
async
{
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
int
>
accepted
=
<
int
>[];
final
List
<
DragTargetDetails
<
int
>>
acceptedDetails
=
<
DragTargetDetails
<
int
>>[];
int
dragStartedCount
=
0
;
int
dragStartedCount
=
0
;
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -2305,6 +2457,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
...
@@ -2305,6 +2457,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
return
Container
(
height:
100.0
,
child:
const
Text
(
'Target'
));
},
},
onAccept:
accepted
.
add
,
onAccept:
accepted
.
add
,
onAcceptWithDetails:
acceptedDetails
.
add
,
),
),
],
],
),
),
...
@@ -2315,6 +2468,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
...
@@ -2315,6 +2468,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
);
);
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Dragging'
),
findsNothing
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -2325,6 +2479,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
...
@@ -2325,6 +2479,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
@@ -2336,6 +2491,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
...
@@ -2336,6 +2491,7 @@ Future<void> _testChildAnchorFeedbackPosition({ WidgetTester tester, double top
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
accepted
,
isEmpty
);
expect
(
accepted
,
isEmpty
);
expect
(
acceptedDetails
,
isEmpty
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Source'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Dragging'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
expect
(
find
.
text
(
'Target'
),
findsOneWidget
);
...
...
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