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
7e96d89a
Unverified
Commit
7e96d89a
authored
Jul 19, 2022
by
Tong Mu
Committed by
GitHub
Jul 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PointerEvent asserts device kinds (#105987)
parent
54bd6297
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
35 deletions
+39
-35
converter.dart
packages/flutter/lib/src/gestures/converter.dart
+0
-3
events.dart
packages/flutter/lib/src/gestures/events.dart
+27
-20
drag_test.dart
packages/flutter/test/gestures/drag_test.dart
+3
-3
scale_test.dart
packages/flutter/test/gestures/scale_test.dart
+6
-6
test_pointer.dart
packages/flutter_test/lib/src/test_pointer.dart
+3
-3
No files found.
packages/flutter/lib/src/gestures/converter.dart
View file @
7e96d89a
...
...
@@ -216,7 +216,6 @@ class PointerEventConverter {
return
PointerPanZoomStartEvent
(
timeStamp:
timeStamp
,
pointer:
datum
.
pointerIdentifier
,
kind:
kind
,
device:
datum
.
device
,
position:
position
,
embedderId:
datum
.
embedderId
,
...
...
@@ -230,7 +229,6 @@ class PointerEventConverter {
return
PointerPanZoomUpdateEvent
(
timeStamp:
timeStamp
,
pointer:
datum
.
pointerIdentifier
,
kind:
kind
,
device:
datum
.
device
,
position:
position
,
pan:
pan
,
...
...
@@ -244,7 +242,6 @@ class PointerEventConverter {
return
PointerPanZoomEndEvent
(
timeStamp:
timeStamp
,
pointer:
datum
.
pointerIdentifier
,
kind:
kind
,
device:
datum
.
device
,
position:
position
,
embedderId:
datum
.
embedderId
,
...
...
packages/flutter/lib/src/gestures/events.dart
View file @
7e96d89a
...
...
@@ -1035,7 +1035,10 @@ class PointerHoverEvent extends PointerEvent with _PointerEventDescription, _Cop
super
.
tilt
,
super
.
synthesized
,
super
.
embedderId
,
})
:
super
(
})
:
// Dart doesn't support comparing enums with == in const contexts yet.
// https://github.com/dart-lang/language/issues/1811
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
down:
false
,
pressure:
0.0
,
);
...
...
@@ -1153,7 +1156,8 @@ class PointerEnterEvent extends PointerEvent with _PointerEventDescription, _Cop
super
.
down
,
super
.
synthesized
,
super
.
embedderId
,
})
:
super
(
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
pressure:
0.0
,
);
...
...
@@ -1297,7 +1301,8 @@ class PointerExitEvent extends PointerEvent with _PointerEventDescription, _Copy
super
.
down
,
super
.
synthesized
,
super
.
embedderId
,
})
:
super
(
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
pressure:
0.0
,
);
...
...
@@ -1432,7 +1437,8 @@ class PointerDownEvent extends PointerEvent with _PointerEventDescription, _Copy
super
.
orientation
,
super
.
tilt
,
super
.
embedderId
,
})
:
super
(
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
down:
true
,
distance:
0.0
,
);
...
...
@@ -1548,7 +1554,8 @@ class PointerMoveEvent extends PointerEvent with _PointerEventDescription, _Copy
super
.
platformData
,
super
.
synthesized
,
super
.
embedderId
,
})
:
super
(
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
down:
true
,
distance:
0.0
,
);
...
...
@@ -1662,7 +1669,8 @@ class PointerUpEvent extends PointerEvent with _PointerEventDescription, _CopyPo
super
.
orientation
,
super
.
tilt
,
super
.
embedderId
,
})
:
super
(
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
down:
false
,
);
...
...
@@ -1711,7 +1719,7 @@ abstract class PointerSignalEvent extends PointerEvent {
super
.
device
,
super
.
position
,
super
.
embedderId
,
});
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
))
;
}
mixin
_CopyPointerScrollEvent
on
PointerEvent
{
...
...
@@ -1849,9 +1857,9 @@ mixin _CopyPointerPanZoomStartEvent on PointerEvent {
bool
?
synthesized
,
int
?
embedderId
,
})
{
assert
(
kind
==
null
||
identical
(
kind
,
PointerDeviceKind
.
trackpad
));
return
PointerPanZoomStartEvent
(
timeStamp:
timeStamp
??
this
.
timeStamp
,
kind:
kind
??
this
.
kind
,
device:
device
??
this
.
device
,
position:
position
??
this
.
position
,
embedderId:
embedderId
??
this
.
embedderId
,
...
...
@@ -1871,19 +1879,18 @@ class PointerPanZoomStartEvent extends PointerEvent with _PointerEventDescriptio
/// All of the arguments must be non-null.
const
PointerPanZoomStartEvent
({
super
.
timeStamp
,
super
.
kind
=
PointerDeviceKind
.
mouse
,
super
.
device
,
super
.
pointer
,
super
.
position
,
super
.
embedderId
,
super
.
synthesized
,
})
:
assert
(
timeStamp
!=
null
),
assert
(
kind
!=
null
),
assert
(
device
!=
null
),
assert
(
pointer
!=
null
),
assert
(
position
!=
null
),
assert
(
embedderId
!=
null
),
assert
(
synthesized
!=
null
);
assert
(
synthesized
!=
null
),
super
(
kind:
PointerDeviceKind
.
trackpad
);
@override
PointerPanZoomStartEvent
transformed
(
Matrix4
?
transform
)
{
...
...
@@ -1953,9 +1960,9 @@ mixin _CopyPointerPanZoomUpdateEvent on PointerEvent {
double
?
scale
,
double
?
rotation
,
})
{
assert
(
kind
==
null
||
identical
(
kind
,
PointerDeviceKind
.
trackpad
));
return
PointerPanZoomUpdateEvent
(
timeStamp:
timeStamp
??
this
.
timeStamp
,
kind:
kind
??
this
.
kind
,
device:
device
??
this
.
device
,
position:
position
??
this
.
position
,
embedderId:
embedderId
??
this
.
embedderId
,
...
...
@@ -1979,7 +1986,6 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti
/// All of the arguments must be non-null.
const
PointerPanZoomUpdateEvent
({
super
.
timeStamp
,
super
.
kind
=
PointerDeviceKind
.
mouse
,
super
.
device
,
super
.
pointer
,
super
.
position
,
...
...
@@ -1990,7 +1996,6 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti
this
.
rotation
=
0.0
,
super
.
synthesized
,
})
:
assert
(
timeStamp
!=
null
),
assert
(
kind
!=
null
),
assert
(
device
!=
null
),
assert
(
pointer
!=
null
),
assert
(
position
!=
null
),
...
...
@@ -1999,7 +2004,9 @@ class PointerPanZoomUpdateEvent extends PointerEvent with _PointerEventDescripti
assert
(
panDelta
!=
null
),
assert
(
scale
!=
null
),
assert
(
rotation
!=
null
),
assert
(
synthesized
!=
null
);
assert
(
synthesized
!=
null
),
super
(
kind:
PointerDeviceKind
.
trackpad
);
@override
final
Offset
pan
;
@override
...
...
@@ -2085,9 +2092,9 @@ mixin _CopyPointerPanZoomEndEvent on PointerEvent {
bool
?
synthesized
,
int
?
embedderId
,
})
{
assert
(
kind
==
null
||
identical
(
kind
,
PointerDeviceKind
.
trackpad
));
return
PointerPanZoomEndEvent
(
timeStamp:
timeStamp
??
this
.
timeStamp
,
kind:
kind
??
this
.
kind
,
device:
device
??
this
.
device
,
position:
position
??
this
.
position
,
embedderId:
embedderId
??
this
.
embedderId
,
...
...
@@ -2107,19 +2114,18 @@ class PointerPanZoomEndEvent extends PointerEvent with _PointerEventDescription,
/// All of the arguments must be non-null.
const
PointerPanZoomEndEvent
({
super
.
timeStamp
,
super
.
kind
=
PointerDeviceKind
.
mouse
,
super
.
device
,
super
.
pointer
,
super
.
position
,
super
.
embedderId
,
super
.
synthesized
,
})
:
assert
(
timeStamp
!=
null
),
assert
(
kind
!=
null
),
assert
(
device
!=
null
),
assert
(
pointer
!=
null
),
assert
(
position
!=
null
),
assert
(
embedderId
!=
null
),
assert
(
synthesized
!=
null
);
assert
(
synthesized
!=
null
),
super
(
kind:
PointerDeviceKind
.
trackpad
);
@override
PointerPanZoomEndEvent
transformed
(
Matrix4
?
transform
)
{
...
...
@@ -2224,7 +2230,8 @@ class PointerCancelEvent extends PointerEvent with _PointerEventDescription, _Co
super
.
orientation
,
super
.
tilt
,
super
.
embedderId
,
})
:
super
(
})
:
assert
(!
identical
(
kind
,
PointerDeviceKind
.
trackpad
)),
super
(
down:
false
,
pressure:
0.0
,
);
...
...
packages/flutter/test/gestures/drag_test.dart
View file @
7e96d89a
...
...
@@ -1507,7 +1507,7 @@ void main() {
didEndPan
=
true
;
};
final
TestPointer
pointer
=
TestPointer
(
2
);
final
TestPointer
pointer
=
TestPointer
(
2
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
start
=
pointer
.
panZoomStart
(
const
Offset
(
10.0
,
10.0
));
pan
.
addPointerPanZoom
(
start
);
competingPan
.
addPointerPanZoom
(
start
);
...
...
@@ -1564,7 +1564,7 @@ void main() {
didEndPan
=
true
;
};
final
TestPointer
panZoomPointer
=
TestPointer
(
2
);
final
TestPointer
panZoomPointer
=
TestPointer
(
2
,
PointerDeviceKind
.
trackpad
);
final
TestPointer
touchPointer
=
TestPointer
(
3
);
final
PointerPanZoomStartEvent
start
=
panZoomPointer
.
panZoomStart
(
const
Offset
(
10.0
,
10.0
));
pan
.
addPointerPanZoom
(
start
);
...
...
@@ -1641,7 +1641,7 @@ testGesture('Touch drags should allow pointer pan/zooms to join them', (GestureT
didEndPan
=
true
;
};
final
TestPointer
panZoomPointer
=
TestPointer
(
2
);
final
TestPointer
panZoomPointer
=
TestPointer
(
2
,
PointerDeviceKind
.
trackpad
);
final
TestPointer
touchPointer
=
TestPointer
(
3
);
final
PointerDownEvent
touchDown
=
touchPointer
.
down
(
const
Offset
(
20.0
,
20.0
));
pan
.
addPointer
(
touchDown
);
...
...
packages/flutter/test/gestures/scale_test.dart
View file @
7e96d89a
...
...
@@ -732,7 +732,7 @@ void main() {
didEndScale
=
true
;
};
final
TestPointer
pointer1
=
TestPointer
(
2
);
final
TestPointer
pointer1
=
TestPointer
(
2
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
start
=
pointer1
.
panZoomStart
(
Offset
.
zero
);
scale
.
addPointerPanZoom
(
start
);
...
...
@@ -836,7 +836,7 @@ void main() {
final
TestPointer
touchPointer1
=
TestPointer
(
2
);
final
TestPointer
touchPointer2
=
TestPointer
(
3
);
final
TestPointer
panZoomPointer
=
TestPointer
(
4
);
final
TestPointer
panZoomPointer
=
TestPointer
(
4
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
panZoomStart
=
panZoomPointer
.
panZoomStart
(
Offset
.
zero
);
scale
.
addPointerPanZoom
(
panZoomStart
);
...
...
@@ -985,7 +985,7 @@ void main() {
drag
.
onStart
=
(
DragStartDetails
details
)
{
log
.
add
(
'drag-start'
);
};
drag
.
onEnd
=
(
DragEndDetails
details
)
{
log
.
add
(
'drag-end'
);
};
final
TestPointer
pointer1
=
TestPointer
(
2
);
final
TestPointer
pointer1
=
TestPointer
(
2
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
down
=
pointer1
.
panZoomStart
(
const
Offset
(
10.0
,
10.0
));
scale
.
addPointerPanZoom
(
down
);
...
...
@@ -1004,7 +1004,7 @@ void main() {
expect
(
log
,
equals
(<
String
>[
'scale-start'
,
'scale-update'
]));
log
.
clear
();
final
TestPointer
pointer2
=
TestPointer
(
3
);
final
TestPointer
pointer2
=
TestPointer
(
3
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
down2
=
pointer2
.
panZoomStart
(
const
Offset
(
10.0
,
20.0
));
scale
.
addPointerPanZoom
(
down2
);
drag
.
addPointerPanZoom
(
down2
);
...
...
@@ -1033,7 +1033,7 @@ void main() {
// TODO(ianh): https://github.com/flutter/flutter/issues/11384
// In this case, we move fast, so that the scale wins. If we moved slowly,
// the horizontal drag would win, since it was added first.
final
TestPointer
pointer3
=
TestPointer
(
4
);
final
TestPointer
pointer3
=
TestPointer
(
4
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
down3
=
pointer3
.
panZoomStart
(
const
Offset
(
30.0
,
30.0
));
scale
.
addPointerPanZoom
(
down3
);
drag
.
addPointerPanZoom
(
down3
);
...
...
@@ -1084,7 +1084,7 @@ void main() {
didEndScale
=
true
;
};
final
TestPointer
pointer1
=
TestPointer
(
2
);
final
TestPointer
pointer1
=
TestPointer
(
2
,
PointerDeviceKind
.
trackpad
);
final
PointerPanZoomStartEvent
start
=
pointer1
.
panZoomStart
(
Offset
.
zero
);
scale
.
addPointerPanZoom
(
start
);
...
...
packages/flutter_test/lib/src/test_pointer.dart
View file @
7e96d89a
...
...
@@ -314,12 +314,12 @@ class TestPointer {
Duration
timeStamp
=
Duration
.
zero
})
{
assert
(!
isPanZoomActive
);
assert
(
kind
==
PointerDeviceKind
.
trackpad
);
_location
=
location
;
_pan
=
Offset
.
zero
;
_isPanZoomActive
=
true
;
return
PointerPanZoomStartEvent
(
timeStamp:
timeStamp
,
kind:
kind
,
device:
_device
,
pointer:
pointer
,
position:
location
,
...
...
@@ -341,12 +341,12 @@ class TestPointer {
Duration
timeStamp
=
Duration
.
zero
,
})
{
assert
(
isPanZoomActive
);
assert
(
kind
==
PointerDeviceKind
.
trackpad
);
_location
=
location
;
final
Offset
panDelta
=
pan
-
_pan
!;
_pan
=
pan
;
return
PointerPanZoomUpdateEvent
(
timeStamp:
timeStamp
,
kind:
kind
,
device:
_device
,
pointer:
pointer
,
position:
location
,
...
...
@@ -366,11 +366,11 @@ class TestPointer {
Duration
timeStamp
=
Duration
.
zero
})
{
assert
(
isPanZoomActive
);
assert
(
kind
==
PointerDeviceKind
.
trackpad
);
_isPanZoomActive
=
false
;
_pan
=
null
;
return
PointerPanZoomEndEvent
(
timeStamp:
timeStamp
,
kind:
kind
,
device:
_device
,
pointer:
pointer
,
position:
location
!,
...
...
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