Pointer events: Allow hover events from trackpad (#108116)

This commit is contained in:
Tong Mu 2022-07-21 10:37:04 -07:00 committed by GitHub
parent fc3471fd28
commit c8a4c8b8a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -1035,10 +1035,7 @@ class PointerHoverEvent extends PointerEvent with _PointerEventDescription, _Cop
super.tilt,
super.synthesized,
super.embedderId,
}) : // 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(
}) : super(
down: false,
pressure: 0.0,
);
@ -1156,7 +1153,9 @@ class PointerEnterEvent extends PointerEvent with _PointerEventDescription, _Cop
super.down,
super.synthesized,
super.embedderId,
}) : assert(!identical(kind, PointerDeviceKind.trackpad)),
}) : // 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(
pressure: 0.0,
);

View File

@ -844,6 +844,17 @@ void main() {
expect(event.synthesized, empty.synthesized);
});
});
test('Ensure certain event types are allowed', () {
// Regression test for https://github.com/flutter/flutter/issues/107962
expect(const PointerHoverEvent(kind: PointerDeviceKind.trackpad), isNotNull);
// The test passes if it compiles.
});
test('Ensure certain event types are not allowed', () {
expect(() => PointerDownEvent(kind: PointerDeviceKind.trackpad), throwsAssertionError);
});
}
void _expectTransformedEvent({