Migrate gestures, physics and scheduler tests to null safety. (#62701)

This commit is contained in:
Darren Austin 2020-10-05 16:01:34 -07:00 committed by GitHub
parent f3d9bf7b7c
commit 01e8c39534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 276 additions and 356 deletions

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import '../flutter_test_alternative.dart';
@ -34,12 +32,12 @@ class GestureTester {
TestGestureArenaMember first = TestGestureArenaMember();
TestGestureArenaMember second = TestGestureArenaMember();
GestureArenaEntry firstEntry;
late GestureArenaEntry firstEntry;
void addFirst() {
firstEntry = arena.add(primaryKey, first);
}
GestureArenaEntry secondEntry;
late GestureArenaEntry secondEntry;
void addSecond() {
secondEntry = arena.add(primaryKey, second);
}

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
@ -14,7 +12,7 @@ void main() {
debugPrintGestureArenaDiagnostics = true;
final DebugPrintCallback oldCallback = debugPrint;
final List<String> log = <String>[];
debugPrint = (String s, { int wrapWidth }) { log.add(s); };
debugPrint = (String? s, { int? wrapWidth }) { log.add(s ?? ''); };
final TapGestureRecognizer tap = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) { }
@ -30,19 +28,19 @@ void main() {
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Adding: TapGestureRecognizer#00000(state: ready, button: 1)'));
log.clear();
GestureBinding.instance.gestureArena.close(1);
GestureBinding.instance!.gestureArena.close(1);
expect(log, hasLength(1));
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Closing with 1 member.'));
log.clear();
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
expect(log, isEmpty);
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
expect(log, isEmpty);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(log, hasLength(2));
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Sweeping with 1 member.'));
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Winner: TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1)'));
@ -60,7 +58,7 @@ void main() {
debugPrintRecognizerCallbacksTrace = true;
final DebugPrintCallback oldCallback = debugPrint;
final List<String> log = <String>[];
debugPrint = (String s, { int wrapWidth }) { log.add(s); };
debugPrint = (String? s, { int? wrapWidth }) { log.add(s ?? ''); };
final TapGestureRecognizer tap = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) { }
@ -73,17 +71,17 @@ void main() {
tap.addPointer(event as PointerDownEvent);
expect(log, isEmpty);
GestureBinding.instance.gestureArena.close(1);
GestureBinding.instance!.gestureArena.close(1);
expect(log, isEmpty);
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
expect(log, isEmpty);
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
expect(log, isEmpty);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(log, hasLength(3));
expect(log[0], equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1) calling onTapDown callback.'));
expect(log[1], equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready, won arena, finalPosition: Offset(12.0, 8.0), button: 1, sent tap down) calling onTapUp callback.'));
@ -103,7 +101,7 @@ void main() {
debugPrintRecognizerCallbacksTrace = true;
final DebugPrintCallback oldCallback = debugPrint;
final List<String> log = <String>[];
debugPrint = (String s, { int wrapWidth }) { log.add(s); };
debugPrint = (String? s, { int? wrapWidth }) { log.add(s ?? ''); };
final TapGestureRecognizer tap = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) { }
@ -119,19 +117,19 @@ void main() {
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Adding: TapGestureRecognizer#00000(state: ready, button: 1)'));
log.clear();
GestureBinding.instance.gestureArena.close(1);
GestureBinding.instance!.gestureArena.close(1);
expect(log, hasLength(1));
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Closing with 1 member.'));
log.clear();
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
expect(log, isEmpty);
event = const PointerUpEvent(pointer: 1, position: Offset(12.0, 8.0));
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
expect(log, isEmpty);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(log, hasLength(5));
expect(log[0], equalsIgnoringHashCodes('Gesture arena 1 ❙ Sweeping with 1 member.'));
expect(log[1], equalsIgnoringHashCodes('Gesture arena 1 ❙ Winner: TapGestureRecognizer#00000(state: ready, finalPosition: Offset(12.0, 8.0), button: 1)'));

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import 'package:fake_async/fake_async.dart';
@ -26,10 +24,10 @@ class TestGestureArenaMember extends GestureArenaMember {
}
void main() {
DoubleTapGestureRecognizer tap;
bool doubleTapRecognized;
TapDownDetails doubleTapDownDetails;
bool doubleTapCanceled;
late DoubleTapGestureRecognizer tap;
bool doubleTapRecognized = false;
TapDownDetails? doubleTapDownDetails;
bool doubleTapCanceled = false;
setUp(() {
ensureGestureBinding();
@ -135,21 +133,21 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(doubleTapDownDetails, isNull);
tester.async.elapse(const Duration(milliseconds: 100));
tap.addPointer(down2);
tester.closeArena(2);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down2.position);
expect(doubleTapDownDetails.localPosition, down2.localPosition);
expect(doubleTapDownDetails!.globalPosition, down2.position);
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
tester.route(down2);
expect(doubleTapRecognized, isFalse);
tester.route(up2);
expect(doubleTapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapCanceled, isFalse);
});
@ -158,13 +156,13 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tap.addPointer(down3);
tester.closeArena(3);
tester.route(down3);
tester.route(up3);
GestureBinding.instance.gestureArena.sweep(3);
GestureBinding.instance!.gestureArena.sweep(3);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -178,13 +176,13 @@ void main() {
tester.route(move4);
tester.route(up4);
GestureBinding.instance.gestureArena.sweep(4);
GestureBinding.instance!.gestureArena.sweep(4);
tap.addPointer(down1);
tester.closeArena(1);
tester.route(down2);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -196,14 +194,14 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.async.elapse(const Duration(milliseconds: 5000));
tap.addPointer(down2);
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -215,14 +213,14 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.async.elapse(const Duration(milliseconds: 5000));
tap.addPointer(down2);
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapDownDetails, isNull);
tester.async.elapse(const Duration(milliseconds: 100));
@ -231,12 +229,12 @@ void main() {
tester.route(down5);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down5.position);
expect(doubleTapDownDetails.localPosition, down5.localPosition);
expect(doubleTapDownDetails!.globalPosition, down5.position);
expect(doubleTapDownDetails!.localPosition, down5.localPosition);
tester.route(up5);
expect(doubleTapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(5);
GestureBinding.instance!.gestureArena.sweep(5);
expect(doubleTapCanceled, isFalse);
});
@ -246,7 +244,7 @@ void main() {
tester.route(down1);
tester.async.elapse(const Duration(milliseconds: 1000));
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(doubleTapDownDetails, isNull);
tap.addPointer(down2);
@ -254,12 +252,12 @@ void main() {
tester.route(down2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down2.position);
expect(doubleTapDownDetails.localPosition, down2.localPosition);
expect(doubleTapDownDetails!.globalPosition, down2.position);
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
tester.route(up2);
expect(doubleTapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapCanceled, isFalse);
});
@ -273,10 +271,10 @@ void main() {
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -293,10 +291,10 @@ void main() {
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapDownDetails, isNull);
tester.async.elapse(const Duration(milliseconds: 100));
@ -305,32 +303,32 @@ void main() {
tester.route(down1);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down1.position);
expect(doubleTapDownDetails.localPosition, down1.localPosition);
expect(doubleTapDownDetails!.globalPosition, down1.position);
expect(doubleTapDownDetails!.localPosition, down1.localPosition);
tester.route(up1);
expect(doubleTapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(doubleTapCanceled, isFalse);
});
testGesture('Should cancel on arena reject during first tap', (GestureTester tester) {
tap.addPointer(down1);
final TestGestureArenaMember member = TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
entry.resolve(GestureDisposition.accepted);
expect(member.accepted, isTrue);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tap.addPointer(down2);
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -340,11 +338,11 @@ void main() {
testGesture('Should cancel on arena reject between taps', (GestureTester tester) {
tap.addPointer(down1);
final TestGestureArenaMember member = TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
entry.resolve(GestureDisposition.accepted);
expect(member.accepted, isTrue);
@ -353,7 +351,7 @@ void main() {
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -363,11 +361,11 @@ void main() {
testGesture('Should cancel on arena reject during last tap', (GestureTester tester) {
tap.addPointer(down1);
final TestGestureArenaMember member = TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(doubleTapDownDetails, isNull);
tester.async.elapse(const Duration(milliseconds: 100));
@ -375,8 +373,8 @@ void main() {
tester.closeArena(2);
tester.route(down2);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down2.position);
expect(doubleTapDownDetails.localPosition, down2.localPosition);
expect(doubleTapDownDetails!.globalPosition, down2.position);
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
expect(doubleTapCanceled, isFalse);
entry.resolve(GestureDisposition.accepted);
@ -384,7 +382,7 @@ void main() {
expect(doubleTapCanceled, isTrue);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
});
@ -392,11 +390,11 @@ void main() {
FakeAsync().run((FakeAsync async) {
tap.addPointer(down1);
final TestGestureArenaMember member = TestGestureArenaMember();
GestureBinding.instance.gestureArena.add(1, member);
GestureBinding.instance!.gestureArena.add(1, member);
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(member.accepted, isFalse);
async.elapse(const Duration(milliseconds: 5000));
@ -413,14 +411,14 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.async.elapse(const Duration(milliseconds: 10));
tap.addPointer(down2);
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -432,14 +430,14 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.async.elapse(const Duration(milliseconds: 10));
tap.addPointer(down2);
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapDownDetails, isNull);
tester.async.elapse(const Duration(milliseconds: 100));
@ -448,12 +446,12 @@ void main() {
tester.route(down5);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down5.position);
expect(doubleTapDownDetails.localPosition, down5.localPosition);
expect(doubleTapDownDetails!.globalPosition, down5.position);
expect(doubleTapDownDetails!.localPosition, down5.localPosition);
tester.route(up5);
expect(doubleTapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(5);
GestureBinding.instance!.gestureArena.sweep(5);
expect(doubleTapCanceled, isFalse);
});
@ -470,7 +468,7 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
tester.async.elapse(interval);
@ -478,7 +476,7 @@ void main() {
tester.closeArena(6);
tester.route(down6);
tester.route(up6);
GestureBinding.instance.gestureArena.sweep(6);
GestureBinding.instance!.gestureArena.sweep(6);
tester.async.elapse(interval);
expect(doubleTapRecognized, isFalse);
@ -487,7 +485,7 @@ void main() {
tester.closeArena(2);
tester.route(down2);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -505,7 +503,7 @@ void main() {
tester.closeArena(6);
tester.route(down6);
tester.route(up6);
GestureBinding.instance.gestureArena.sweep(6);
GestureBinding.instance!.gestureArena.sweep(6);
tester.async.elapse(interval);
@ -513,7 +511,7 @@ void main() {
tester.closeArena(1);
tester.route(down1);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(doubleTapRecognized, isFalse);
expect(doubleTapDownDetails, isNull);
@ -523,10 +521,10 @@ void main() {
tester.closeArena(2);
tester.route(down2);
expect(doubleTapDownDetails, isNotNull);
expect(doubleTapDownDetails.globalPosition, down2.position);
expect(doubleTapDownDetails.localPosition, down2.localPosition);
expect(doubleTapDownDetails!.globalPosition, down2.position);
expect(doubleTapDownDetails!.localPosition, down2.localPosition);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(doubleTapRecognized, isTrue);
expect(doubleTapCanceled, isFalse);
@ -542,9 +540,9 @@ void main() {
// competition with a tap gesture recognizer listening on a different button.
final List<String> recognized = <String>[];
TapGestureRecognizer tapPrimary;
TapGestureRecognizer tapSecondary;
DoubleTapGestureRecognizer doubleTap;
late TapGestureRecognizer tapPrimary;
late TapGestureRecognizer tapSecondary;
late DoubleTapGestureRecognizer doubleTap;
setUp(() {
tapPrimary = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) {
@ -612,7 +610,7 @@ void main() {
tester.closeArena(6);
tester.route(down6);
tester.route(up6);
GestureBinding.instance.gestureArena.sweep(6);
GestureBinding.instance!.gestureArena.sweep(6);
tester.async.elapse(const Duration(milliseconds: 100));
doubleTap.addPointer(down7);

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@ -24,7 +22,7 @@ void main() {
didStartPan = true;
};
Offset updatedScrollDelta;
Offset? updatedScrollDelta;
pan.onUpdate = (DragUpdateDetails details) {
updatedScrollDelta = details.delta;
};
@ -81,13 +79,13 @@ void main() {
});
testGesture('Should report most recent point to onStart by default', (GestureTester tester) {
HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
final VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
..onStart = (_) {};
addTearDown(() => drag?.dispose);
addTearDown(() => competingDrag?.dispose);
addTearDown(() => drag.dispose);
addTearDown(() => competingDrag.dispose);
Offset positionAtOnStart;
late Offset positionAtOnStart;
drag.onStart = (DragStartDetails details) {
positionAtOnStart = details.globalPosition;
};
@ -100,26 +98,21 @@ void main() {
tester.route(down);
tester.route(pointer.move(const Offset(30.0, 0.0)));
drag.dispose();
drag = null;
competingDrag.dispose();
competingDrag = null;
expect(positionAtOnStart, const Offset(30.0, 00.0));
});
testGesture('Should report most recent point to onStart with a start configuration', (GestureTester tester) {
HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer();
final VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
..onStart = (_) {};
addTearDown(() => drag?.dispose);
addTearDown(() => competingDrag?.dispose);
addTearDown(() => drag.dispose);
addTearDown(() => competingDrag.dispose);
Offset positionAtOnStart;
Offset? positionAtOnStart;
drag.onStart = (DragStartDetails details) {
positionAtOnStart = details.globalPosition;
};
Offset updateOffset;
Offset? updateOffset;
drag.onUpdate = (DragUpdateDetails details) {
updateOffset = details.globalPosition;
};
@ -132,10 +125,6 @@ void main() {
tester.route(down);
tester.route(pointer.move(const Offset(30.0, 0.0)));
drag.dispose();
drag = null;
competingDrag.dispose();
competingDrag = null;
expect(positionAtOnStart, const Offset(30.0, 0.0));
expect(updateOffset, null);
@ -150,7 +139,7 @@ void main() {
didStartDrag = true;
};
double updatedDelta;
double? updatedDelta;
drag.onUpdate = (DragUpdateDetails details) {
updatedDelta = details.primaryDelta;
};
@ -197,12 +186,12 @@ void main() {
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(drag.dispose);
Duration startTimestamp;
Duration? startTimestamp;
drag.onStart = (DragStartDetails details) {
startTimestamp = details.sourceTimeStamp;
};
Duration updatedTimestamp;
Duration? updatedTimestamp;
drag.onUpdate = (DragUpdateDetails details) {
updatedTimestamp = details.sourceTimeStamp;
};
@ -224,20 +213,20 @@ void main() {
});
testGesture('Should report initial down point to onStart with a down configuration', (GestureTester tester) {
HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer()
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer()
..dragStartBehavior = DragStartBehavior.down;
VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
final VerticalDragGestureRecognizer competingDrag = VerticalDragGestureRecognizer()
..dragStartBehavior = DragStartBehavior.down
..onStart = (_) {};
addTearDown(() => drag?.dispose);
addTearDown(() => competingDrag?.dispose);
addTearDown(() => drag.dispose);
addTearDown(() => competingDrag.dispose);
Offset positionAtOnStart;
Offset? positionAtOnStart;
drag.onStart = (DragStartDetails details) {
positionAtOnStart = details.globalPosition;
};
Offset updateOffset;
Offset updateDelta;
Offset? updateOffset;
Offset? updateDelta;
drag.onUpdate = (DragUpdateDetails details) {
updateOffset = details.globalPosition;
updateDelta = details.delta;
@ -251,11 +240,6 @@ void main() {
tester.route(down);
tester.route(pointer.move(const Offset(30.0, 0.0)));
drag.dispose();
drag = null;
competingDrag.dispose();
competingDrag = null;
expect(positionAtOnStart, const Offset(10.0, 10.0));
// The drag is horizontal so we're going to ignore the vertical delta position
@ -265,12 +249,12 @@ void main() {
});
testGesture('Drag with multiple pointers in down behavior', (GestureTester tester) {
HorizontalDragGestureRecognizer drag1 =
HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
VerticalDragGestureRecognizer drag2 =
VerticalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(() => drag1?.dispose);
addTearDown(() => drag2?.dispose);
final HorizontalDragGestureRecognizer drag1 =
HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
final VerticalDragGestureRecognizer drag2 =
VerticalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(() => drag1.dispose);
addTearDown(() => drag2.dispose);
final List<String> log = <String>[];
drag1.onDown = (_) { log.add('drag1-down'); };
@ -313,11 +297,6 @@ void main() {
tester.route(pointer5.up());
tester.route(pointer6.up());
drag1.dispose();
drag1 = null;
drag2.dispose();
drag2 = null;
expect(log, <String>[
'drag1-down',
'drag2-down',
@ -343,8 +322,8 @@ void main() {
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(drag.dispose);
Velocity velocity;
double primaryVelocity;
late Velocity velocity;
double? primaryVelocity;
drag.onEnd = (DragEndDetails details) {
velocity = details.velocity;
primaryVelocity = details.primaryVelocity;
@ -376,7 +355,7 @@ void main() {
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(drag.dispose);
Velocity velocity;
late Velocity velocity;
drag.onEnd = (DragEndDetails details) {
velocity = details.velocity;
};
@ -409,7 +388,7 @@ void main() {
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(drag.dispose);
Velocity velocity;
late Velocity velocity;
drag.onEnd = (DragEndDetails details) {
velocity = details.velocity;
};
@ -443,8 +422,8 @@ void main() {
didStartDrag = true;
};
Offset updateDelta;
double updatePrimaryDelta;
Offset? updateDelta;
double? updatePrimaryDelta;
drag.onUpdate = (DragUpdateDetails details) {
updateDelta = details.delta;
updatePrimaryDelta = details.primaryDelta;
@ -500,11 +479,11 @@ void main() {
final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer() ..dragStartBehavior = DragStartBehavior.down;
addTearDown(drag.dispose);
Offset latestGlobalPosition;
Offset? latestGlobalPosition;
drag.onStart = (DragStartDetails details) {
latestGlobalPosition = details.globalPosition;
};
Offset latestDelta;
Offset? latestDelta;
drag.onUpdate = (DragUpdateDetails details) {
latestGlobalPosition = details.globalPosition;
latestDelta = details.delta;
@ -543,7 +522,7 @@ void main() {
didStartDrag = true;
};
double updatedDelta;
double? updatedDelta;
drag.onUpdate = (DragUpdateDetails details) {
updatedDelta = details.primaryDelta;
};
@ -609,8 +588,8 @@ void main() {
});
group('Enforce consistent-button restriction:', () {
PanGestureRecognizer pan;
TapGestureRecognizer tap;
late PanGestureRecognizer pan;
late TapGestureRecognizer tap;
final List<String> logs = <String>[];
setUp(() {
@ -750,9 +729,9 @@ void main() {
// competition with a tap gesture recognizer listening on a different button.
final List<String> recognized = <String>[];
TapGestureRecognizer tapPrimary;
TapGestureRecognizer tapSecondary;
PanGestureRecognizer pan;
late TapGestureRecognizer tapPrimary;
late TapGestureRecognizer tapSecondary;
late PanGestureRecognizer pan;
setUp(() {
tapPrimary = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) {
@ -938,12 +917,12 @@ void main() {
logs.clear();
tester.route(pointer1.up());
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
expect(logs, <String>['downT', 'upT']);
logs.clear();
tester.route(pointer2.up());
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
expect(logs, <String>['cancelH']);
logs.clear();
},
@ -991,13 +970,13 @@ void main() {
logs.clear();
tester.route(pointer2.up());
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
// Tap is not triggered because pointer2 is not its primary pointer
expect(logs, <String>[]);
logs.clear();
tester.route(pointer1.up());
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
expect(logs, <String>['cancelH', 'downT', 'upT']);
logs.clear();
},
@ -1049,12 +1028,12 @@ void main() {
logs.clear();
tester.route(pointer2.up());
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
expect(logs, <String>[]);
logs.clear();
tester.route(pointer1.up());
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
expect(logs, <String>['endH']);
logs.clear();
},
@ -1102,7 +1081,7 @@ void main() {
logs.clear();
tester.route(pointer1.up());
GestureBinding.instance.gestureArena.sweep(pointer1.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer1.pointer);
expect(logs, <String>['downT', 'upT']);
logs.clear();
@ -1111,7 +1090,7 @@ void main() {
logs.clear();
tester.route(pointer2.up());
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
expect(logs, <String>['endH']);
logs.clear();
},
@ -1167,7 +1146,7 @@ void main() {
logs.clear();
tester.route(pointer2.up());
GestureBinding.instance.gestureArena.sweep(pointer2.pointer);
GestureBinding.instance!.gestureArena.sweep(pointer2.pointer);
expect(logs, <String>['endH']);
logs.clear();
},

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
@ -801,10 +799,10 @@ void main() {
}
void _expectTransformedEvent({
@required PointerEvent original,
@required Matrix4 transform,
Offset localDelta,
Offset localPosition,
required PointerEvent original,
required Matrix4 transform,
Offset? localDelta,
Offset? localPosition,
}) {
expect(original.position, original.localPosition);
expect(original.delta, original.localDelta);

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
@ -28,7 +26,7 @@ void main() {
int updated = 0;
int ended = 0;
Offset startGlobalPosition;
Offset? startGlobalPosition;
void onStart(ForcePressDetails details) {
startGlobalPosition = details.globalPosition;
@ -411,7 +409,7 @@ void main() {
int updated = 0;
int ended = 0;
Offset startGlobalPosition;
Offset? startGlobalPosition;
void onStart(ForcePressDetails details) {
startGlobalPosition = details.globalPosition;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
@ -15,21 +13,21 @@ import '../flutter_test_alternative.dart';
typedef HandleEventCallback = void Function(PointerEvent event);
class TestGestureFlutterBinding extends BindingBase with GestureBinding, SchedulerBinding {
HandleEventCallback callback;
FrameCallback frameCallback;
Duration frameTime;
HandleEventCallback? callback;
FrameCallback? frameCallback;
Duration? frameTime;
@override
void handleEvent(PointerEvent event, HitTestEntry entry) {
super.handleEvent(event, entry);
if (callback != null)
callback(event);
callback?.call(event);
}
@override
Duration get currentSystemFrameTimeStamp {
assert(frameTime != null);
return frameTime;
return frameTime!;
}
@override
@ -39,7 +37,7 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding, Schedul
}
}
TestGestureFlutterBinding _binding = TestGestureFlutterBinding();
TestGestureFlutterBinding? _binding;
void ensureTestGestureBinding() {
_binding ??= TestGestureFlutterBinding();
@ -59,9 +57,9 @@ void main() {
);
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = events.add;
_binding!.callback = events.add;
ui.window.onPointerDataPacket(packet);
ui.window.onPointerDataPacket?.call(packet);
expect(events.length, 2);
expect(events[0], isA<PointerDownEvent>());
expect(events[1], isA<PointerUpEvent>());
@ -77,9 +75,9 @@ void main() {
);
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = events.add;
_binding!.callback = events.add;
ui.window.onPointerDataPacket(packet);
ui.window.onPointerDataPacket?.call(packet);
expect(events.length, 3);
expect(events[0], isA<PointerDownEvent>());
expect(events[1], isA<PointerMoveEvent>());
@ -99,12 +97,12 @@ void main() {
);
final List<PointerEvent> pointerRouterEvents = <PointerEvent>[];
GestureBinding.instance.pointerRouter.addGlobalRoute(pointerRouterEvents.add);
GestureBinding.instance!.pointerRouter.addGlobalRoute(pointerRouterEvents.add);
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = events.add;
_binding!.callback = events.add;
ui.window.onPointerDataPacket(packet);
ui.window.onPointerDataPacket?.call(packet);
expect(events.length, 3);
expect(events[0], isA<PointerHoverEvent>());
expect(events[1], isA<PointerHoverEvent>());
@ -128,9 +126,9 @@ void main() {
);
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = events.add;
_binding!.callback = events.add;
ui.window.onPointerDataPacket(packet);
ui.window.onPointerDataPacket?.call(packet);
expect(events.length, 2);
expect(events[0], isA<PointerDownEvent>());
expect(events[1], isA<PointerCancelEvent>());
@ -145,13 +143,13 @@ void main() {
);
final List<PointerEvent> events = <PointerEvent>[];
_binding.callback = (PointerEvent event) {
_binding!.callback = (PointerEvent event) {
events.add(event);
if (event is PointerDownEvent)
_binding.cancelPointer(event.pointer);
_binding!.cancelPointer(event.pointer);
};
ui.window.onPointerDataPacket(packet);
ui.window.onPointerDataPacket?.call(packet);
expect(events.length, 2);
expect(events[0], isA<PointerDownEvent>());
expect(events[1], isA<PointerCancelEvent>());

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:meta/meta.dart';
@ -25,11 +23,11 @@ class GestureTester {
final FakeAsync async;
void closeArena(int pointer) {
GestureBinding.instance.gestureArena.close(pointer);
GestureBinding.instance!.gestureArena.close(pointer);
}
void route(PointerEvent event) {
GestureBinding.instance.pointerRouter.route(event);
GestureBinding.instance!.pointerRouter.route(event);
async.flushMicrotasks();
}
}

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import 'package:vector_math/vector_math_64.dart';
@ -38,7 +36,7 @@ void main() {
});
test('HitTestResult should correctly push and pop transforms', () {
Matrix4 currentTransform(HitTestResult targetResult) {
Matrix4? currentTransform(HitTestResult targetResult) {
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
targetResult.add(entry);
return entry.transform;
@ -78,7 +76,7 @@ void main() {
});
test('HitTestResult should correctly push and pop offsets', () {
Matrix4 currentTransform(HitTestResult targetResult) {
Matrix4? currentTransform(HitTestResult targetResult) {
final HitTestEntry entry = HitTestEntry(_DummyHitTestTarget());
targetResult.add(entry);
return entry.transform;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:ui' as ui;
import 'package:flutter/foundation.dart';
@ -14,12 +12,12 @@ import '../flutter_test_alternative.dart';
typedef HandleEventCallback = void Function(PointerEvent event);
class TestGestureFlutterBinding extends BindingBase with GestureBinding {
HandleEventCallback callback;
HandleEventCallback? callback;
@override
void handleEvent(PointerEvent event, HitTestEntry entry) {
if (callback != null)
callback(event);
callback?.call(event);
super.handleEvent(event, entry);
}
@ -33,21 +31,17 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding {
Future<void> test(VoidCallback callback) {
assert(callback != null);
return _binding.lockEvents(() async {
ui.window.onPointerDataPacket(packet);
ui.window.onPointerDataPacket?.call(packet);
callback();
});
}
}
TestGestureFlutterBinding _binding = TestGestureFlutterBinding();
void ensureTestGestureBinding() {
_binding ??= TestGestureFlutterBinding();
assert(GestureBinding.instance != null);
}
late TestGestureFlutterBinding _binding;
void main() {
setUp(ensureTestGestureBinding);
_binding = TestGestureFlutterBinding();
assert(GestureBinding.instance != null);
test('Pointer events are locked during reassemble', () async {
final List<PointerEvent> events = <PointerEvent>[];

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import '../flutter_test_alternative.dart';
@ -64,9 +62,9 @@ void main() {
setUp(ensureGestureBinding);
group('Long press', () {
LongPressGestureRecognizer longPress;
bool longPressDown;
bool longPressUp;
late LongPressGestureRecognizer longPress;
late bool longPressDown;
late bool longPressUp;
setUp(() {
longPress = LongPressGestureRecognizer();
@ -293,10 +291,10 @@ void main() {
});
group('long press drag', () {
LongPressGestureRecognizer longPressDrag;
bool longPressStart;
bool longPressUp;
Offset longPressDragUpdate;
late LongPressGestureRecognizer longPressDrag;
late bool longPressStart;
late bool longPressUp;
Offset? longPressDragUpdate;
setUp(() {
longPressDrag = LongPressGestureRecognizer();
@ -392,7 +390,7 @@ void main() {
final List<String> recognized = <String>[];
LongPressGestureRecognizer longPress;
late LongPressGestureRecognizer longPress;
setUp(() {
longPress = LongPressGestureRecognizer()
@ -532,9 +530,9 @@ void main() {
// competition with a tap gesture recognizer listening on a different button.
final List<String> recognized = <String>[];
TapGestureRecognizer tapPrimary;
TapGestureRecognizer tapSecondary;
LongPressGestureRecognizer longPress;
late TapGestureRecognizer tapPrimary;
late TapGestureRecognizer tapSecondary;
late LongPressGestureRecognizer longPress;
setUp(() {
tapPrimary = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) {

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import '../flutter_test_alternative.dart';
@ -20,7 +18,7 @@ void main() {
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(1);
final PolynomialFit fit = solver.solve(1)!;
expect(fit.coefficients.length, 2);
expect(approx(fit.coefficients[0], 1.0), isTrue);
@ -34,7 +32,7 @@ void main() {
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(1);
final PolynomialFit fit = solver.solve(1)!;
expect(fit.coefficients.length, 2);
expect(approx(fit.coefficients[0], 1.0), isTrue);
@ -48,7 +46,7 @@ void main() {
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(2);
final PolynomialFit fit = solver.solve(2)!;
expect(fit.coefficients.length, 3);
expect(approx(fit.coefficients[0], 1.0), isTrue);
@ -63,7 +61,7 @@ void main() {
final List<double> w = <double>[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0];
final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w);
final PolynomialFit fit = solver.solve(2);
final PolynomialFit fit = solver.solve(2)!;
expect(fit.coefficients.length, 3);
expect(approx(fit.coefficients[0], 1.0), isTrue);

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
@ -136,7 +134,7 @@ void main() {
log.add('per-pointer 3');
});
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
final FlutterExceptionHandler? previousErrorHandler = FlutterError.onError;
FlutterError.onError = (FlutterErrorDetails details) {
log.add('error report');
};

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import 'package:vector_math/vector_math_64.dart';

View File

@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
class TestGestureRecognizer extends GestureRecognizer {
TestGestureRecognizer({ Object debugOwner }) : super(debugOwner: debugOwner);
TestGestureRecognizer({ Object? debugOwner }) : super(debugOwner: debugOwner);
@override
String get debugDescription => 'debugDescription content';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math;
import 'package:flutter_test/flutter_test.dart';
@ -19,15 +17,15 @@ void main() {
final TapGestureRecognizer tap = TapGestureRecognizer();
bool didStartScale = false;
Offset updatedFocalPoint;
Offset? updatedFocalPoint;
scale.onStart = (ScaleStartDetails details) {
didStartScale = true;
updatedFocalPoint = details.focalPoint;
};
double updatedScale;
double updatedHorizontalScale;
double updatedVerticalScale;
double? updatedScale;
double? updatedHorizontalScale;
double? updatedVerticalScale;
scale.onUpdate = (ScaleUpdateDetails details) {
updatedScale = details.scale;
updatedHorizontalScale = details.horizontalScale;
@ -230,7 +228,7 @@ void main() {
didStartScale = true;
};
double updatedScale;
double? updatedScale;
scale.onUpdate = (ScaleUpdateDetails details) {
updatedScale = details.scale;
};
@ -258,13 +256,13 @@ void main() {
final ScaleGestureRecognizer scale = ScaleGestureRecognizer(kind: PointerDeviceKind.touch);
bool didStartScale = false;
Offset updatedFocalPoint;
Offset? updatedFocalPoint;
scale.onStart = (ScaleStartDetails details) {
didStartScale = true;
updatedFocalPoint = details.focalPoint;
};
double updatedScale;
double? updatedScale;
scale.onUpdate = (ScaleUpdateDetails details) {
updatedScale = details.scale;
updatedFocalPoint = details.focalPoint;
@ -404,13 +402,13 @@ void main() {
final TapGestureRecognizer tap = TapGestureRecognizer();
bool didStartScale = false;
Offset updatedFocalPoint;
Offset? updatedFocalPoint;
scale.onStart = (ScaleStartDetails details) {
didStartScale = true;
updatedFocalPoint = details.focalPoint;
};
double updatedRotation;
double? updatedRotation;
scale.onUpdate = (ScaleUpdateDetails details) {
updatedRotation = details.rotation;
updatedFocalPoint = details.focalPoint;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
@ -115,7 +113,7 @@ void main() {
tester.route(up1);
expect(tapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapRecognized, isTrue);
tap.dispose();
@ -124,8 +122,8 @@ void main() {
testGesture('Details contain the correct device kind', (GestureTester tester) {
final TapGestureRecognizer tap = TapGestureRecognizer();
TapDownDetails lastDownDetails;
TapUpDetails lastUpDetails;
TapDownDetails? lastDownDetails;
TapUpDetails? lastUpDetails;
tap.onTapDown = (TapDownDetails details) {
lastDownDetails = details;
@ -142,10 +140,10 @@ void main() {
tap.addPointer(mouseDown);
tester.closeArena(1);
tester.route(mouseDown);
expect(lastDownDetails.kind, PointerDeviceKind.mouse);
expect(lastDownDetails?.kind, PointerDeviceKind.mouse);
tester.route(mouseUp);
expect(lastUpDetails.kind, PointerDeviceKind.mouse);
expect(lastUpDetails?.kind, PointerDeviceKind.mouse);
tap.dispose();
});
@ -166,7 +164,7 @@ void main() {
tester.route(up1);
expect(tapsRecognized, 1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapsRecognized, 1);
tap.addPointer(down1);
@ -177,7 +175,7 @@ void main() {
tester.route(up1);
expect(tapsRecognized, 2);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapsRecognized, 2);
tap.dispose();
@ -206,12 +204,12 @@ void main() {
tester.route(up1);
expect(tapsRecognized, 1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapsRecognized, 1);
tester.route(up2);
expect(tapsRecognized, 1);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(tapsRecognized, 1);
tap.dispose();
@ -240,12 +238,12 @@ void main() {
tester.route(up2);
expect(tapsRecognized, 0);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(tapsRecognized, 0);
tester.route(up1);
expect(tapsRecognized, 1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapsRecognized, 1);
tap.dispose();
@ -277,7 +275,7 @@ void main() {
tester.route(up3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
GestureBinding.instance.gestureArena.sweep(3);
GestureBinding.instance!.gestureArena.sweep(3);
expect(tapRecognized, isFalse);
expect(tapCanceled, isTrue);
@ -310,7 +308,7 @@ void main() {
tester.route(up4);
expect(tapRecognized, isTrue);
expect(tapCanceled, isFalse);
GestureBinding.instance.gestureArena.sweep(4);
GestureBinding.instance!.gestureArena.sweep(4);
expect(tapRecognized, isTrue);
expect(tapCanceled, isFalse);
@ -335,7 +333,7 @@ void main() {
expect(tapRecognized, isFalse);
tester.route(up1);
expect(tapRecognized, isTrue);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapRecognized, isTrue);
tap.dispose();
@ -351,8 +349,8 @@ void main() {
tap.addPointer(down1);
final TestGestureArenaMember member = TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
GestureBinding.instance.gestureArena.hold(1);
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
GestureBinding.instance!.gestureArena.hold(1);
tester.closeArena(1);
expect(tapRecognized, isFalse);
tester.route(down1);
@ -360,7 +358,7 @@ void main() {
tester.route(up1);
expect(tapRecognized, isFalse);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapRecognized, isFalse);
entry.resolve(GestureDisposition.accepted);
@ -379,8 +377,8 @@ void main() {
tap.addPointer(down1);
final TestGestureArenaMember member = TestGestureArenaMember();
final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member);
GestureBinding.instance.gestureArena.hold(1);
final GestureArenaEntry entry = GestureBinding.instance!.gestureArena.add(1, member);
GestureBinding.instance!.gestureArena.hold(1);
tester.closeArena(1);
expect(tapRecognized, isFalse);
tester.route(down1);
@ -388,7 +386,7 @@ void main() {
tester.route(up1);
expect(tapRecognized, isFalse);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(tapRecognized, isFalse);
entry.resolve(GestureDisposition.rejected);
@ -405,7 +403,7 @@ void main() {
throw Exception(test);
};
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
final FlutterExceptionHandler? previousErrorHandler = FlutterError.onError;
bool gotError = false;
FlutterError.onError = (FlutterErrorDetails details) {
gotError = true;
@ -430,7 +428,7 @@ void main() {
throw Exception(test);
};
final FlutterExceptionHandler previousErrorHandler = FlutterError.onError;
final FlutterExceptionHandler? previousErrorHandler = FlutterError.onError;
bool gotError = false;
FlutterError.onError = (FlutterErrorDetails details) {
expect(details.toString().contains('"spontaneous onTapCancel"') , isTrue);
@ -474,7 +472,7 @@ void main() {
log.add('routed 1 down');
tester.route(up1);
log.add('routed 1 up');
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
log.add('swept 1');
tapA.addPointer(down2);
log.add('down 2 to A');
@ -486,7 +484,7 @@ void main() {
log.add('routed 2 down');
tester.route(up2);
log.add('routed 2 up');
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
log.add('swept 2');
tapA.dispose();
log.add('disposed A');
@ -618,7 +616,7 @@ void main() {
drag.addPointer(down3);
tester.closeArena(3);
tester.route(move3);
GestureBinding.instance.gestureArena.sweep(3);
GestureBinding.instance!.gestureArena.sweep(3);
expect(recognized, isEmpty);
tap.dispose();
@ -655,7 +653,7 @@ void main() {
expect(recognized, isEmpty);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(down1.pointer);
GestureBinding.instance!.gestureArena.sweep(down1.pointer);
expect(recognized, <String>['down', 'up', 'tap']);
recognized.clear();
@ -664,7 +662,7 @@ void main() {
expect(recognized, isEmpty);
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(down2.pointer);
GestureBinding.instance!.gestureArena.sweep(down2.pointer);
expect(recognized, isEmpty);
tap.dispose();
@ -684,7 +682,7 @@ void main() {
);
final List<String> recognized = <String>[];
TapGestureRecognizer tap;
late TapGestureRecognizer tap;
setUp(() {
tap = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) {
@ -765,14 +763,14 @@ void main() {
tester.route(move1lr);
tester.route(move1r);
tester.route(up1);
GestureBinding.instance.gestureArena.sweep(1);
GestureBinding.instance!.gestureArena.sweep(1);
expect(recognized, <String>['down', 'cancel']);
tap.addPointer(down2);
tester.closeArena(2);
tester.async.elapse(const Duration(milliseconds: 1000));
tester.route(up2);
GestureBinding.instance.gestureArena.sweep(2);
GestureBinding.instance!.gestureArena.sweep(2);
expect(recognized, <String>['down', 'cancel', 'down', 'up']);
tap.dispose();
@ -786,10 +784,10 @@ void main() {
// listening on different buttons do not form competition.
final List<String> recognized = <String>[];
TapGestureRecognizer primary;
TapGestureRecognizer primary2;
TapGestureRecognizer secondary;
TapGestureRecognizer tertiary;
late TapGestureRecognizer primary;
late TapGestureRecognizer primary2;
late TapGestureRecognizer secondary;
late TapGestureRecognizer tertiary;
setUp(() {
primary = TapGestureRecognizer()
..onTapDown = (TapDownDetails details) {
@ -882,7 +880,7 @@ void main() {
group('Gestures of different buttons trigger correct callbacks:', () {
final List<String> recognized = <String>[];
TapGestureRecognizer tap;
late TapGestureRecognizer tap;
const PointerCancelEvent cancel1 = PointerCancelEvent(
pointer: 1,
);
@ -942,7 +940,7 @@ void main() {
tester.route(up1);
expect(recognized, <String>['primaryUp', 'primary']);
GestureBinding.instance.gestureArena.sweep(down1.pointer);
GestureBinding.instance!.gestureArena.sweep(down1.pointer);
});
testGesture('A primary tap cancel trigger primary callbacks', (GestureTester tester) {
@ -955,7 +953,7 @@ void main() {
tester.route(cancel1);
expect(recognized, <String>['primaryCancel']);
GestureBinding.instance.gestureArena.sweep(down1.pointer);
GestureBinding.instance!.gestureArena.sweep(down1.pointer);
});
testGesture('A secondary tap should trigger secondary callbacks', (GestureTester tester) {
@ -967,7 +965,7 @@ void main() {
recognized.clear();
tester.route(up5);
GestureBinding.instance.gestureArena.sweep(down5.pointer);
GestureBinding.instance!.gestureArena.sweep(down5.pointer);
expect(recognized, <String>['secondaryUp']);
});
@ -980,7 +978,7 @@ void main() {
recognized.clear();
tester.route(up6);
GestureBinding.instance.gestureArena.sweep(down6.pointer);
GestureBinding.instance!.gestureArena.sweep(down6.pointer);
expect(recognized, <String>['tertiaryUp']);
});
@ -993,7 +991,7 @@ void main() {
recognized.clear();
tester.route(cancel5);
GestureBinding.instance.gestureArena.sweep(down5.pointer);
GestureBinding.instance!.gestureArena.sweep(down5.pointer);
expect(recognized, <String>['secondaryCancel']);
});
@ -1006,7 +1004,7 @@ void main() {
recognized.clear();
tester.route(cancel6);
GestureBinding.instance.gestureArena.sweep(down6.pointer);
GestureBinding.instance!.gestureArena.sweep(down6.pointer);
expect(recognized, <String>['tertiaryCancel']);
});
});

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/gestures.dart';
@ -108,7 +106,7 @@ void main() {
typedef GestureAcceptedCallback = void Function();
class PassiveGestureRecognizer extends OneSequenceGestureRecognizer {
GestureAcceptedCallback onGestureAccepted;
GestureAcceptedCallback? onGestureAccepted;
@override
void addPointer(PointerDownEvent event) {
@ -133,7 +131,7 @@ class PassiveGestureRecognizer extends OneSequenceGestureRecognizer {
@override
void acceptGesture(int pointer) {
if (onGestureAccepted != null) {
onGestureAccepted();
onGestureAccepted!();
}
}

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:math' as math;
import 'package:flutter/material.dart';
@ -63,7 +61,7 @@ void main() {
const Offset(100, 0),
);
expect(
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + details.primaryDelta),
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + (details.primaryDelta ?? 0)),
100.0,
);
});
@ -391,7 +389,7 @@ void main() {
const Offset(0, 100),
);
expect(
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + details.primaryDelta),
updateDetails.fold(0.0, (double offset, DragUpdateDetails details) => offset + (details.primaryDelta ?? 0)),
100.0,
);
});

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
const List<PointerEvent> velocityEventData = <PointerEvent>[

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
import 'velocity_tracker_data.dart';
@ -81,7 +79,7 @@ void main() {
test('FreeScrollStartVelocityTracker.getVelocity throws when no points', () {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
AssertionError exception;
AssertionError? exception;
try {
tracker.getVelocity();
} on AssertionError catch (e) {
@ -93,7 +91,7 @@ void main() {
test('FreeScrollStartVelocityTracker.getVelocity throws when the new point precedes the previous point', () {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
AssertionError exception;
AssertionError? exception;
tracker.addPosition(const Duration(hours: 1), Offset.zero);
try {
@ -112,7 +110,7 @@ void main() {
Duration time = Duration.zero;
const Offset positionDelta = Offset(0, -1);
const Duration durationDelta = Duration(seconds: 1);
AssertionError exception;
AssertionError? exception;
for (int i = 0; i < 5; i+=1) {
position += positionDelta;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
@ -22,7 +20,7 @@ void main() {
});
test('Can cancel queued callback', () {
int secondId;
late int secondId;
bool firstCallbackRan = false;
bool secondCallbackRan = false;

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
@ -14,10 +12,10 @@ class TestBinding extends LiveTestWidgetsFlutterBinding {
int framesBegun = 0;
int framesDrawn = 0;
bool handleBeginFrameMicrotaskRun;
late bool handleBeginFrameMicrotaskRun;
@override
void handleBeginFrame(Duration rawTimeStamp) {
void handleBeginFrame(Duration? rawTimeStamp) {
handleBeginFrameMicrotaskRun = false;
framesBegun += 1;
Future<void>.microtask(() { handleBeginFrameMicrotaskRun = true; });
@ -35,7 +33,7 @@ class TestBinding extends LiveTestWidgetsFlutterBinding {
}
void main() {
TestBinding binding;
late TestBinding binding;
setUp(() {
binding = TestBinding();

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/scheduler.dart';
import '../flutter_test_alternative.dart';

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'dart:ui' show window;
@ -30,13 +28,13 @@ class TestSchedulerBinding extends BindingBase with SchedulerBinding, ServicesBi
class TestStrategy {
int allowedPriority = 10000;
bool shouldRunTaskWithPriority({ int priority, SchedulerBinding scheduler }) {
bool shouldRunTaskWithPriority({ required int priority, required SchedulerBinding scheduler }) {
return priority >= allowedPriority;
}
}
void main() {
TestSchedulerBinding scheduler;
late TestSchedulerBinding scheduler;
setUpAll(() {
scheduler = TestSchedulerBinding();
@ -122,7 +120,7 @@ void main() {
createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()) {
// Don't actually run the tasks, just record that it was scheduled.
timerQueueTasks.add(f);
return null;
return DummyTimer();
},
),
);
@ -134,7 +132,7 @@ void main() {
});
test('Flutter.Frame event fired', () async {
window.onReportTimings(<FrameTiming>[FrameTiming(
window.onReportTimings!(<FrameTiming>[FrameTiming(
vsyncStart: 5000,
buildStart: 10000,
buildFinish: 15000,
@ -155,20 +153,20 @@ void main() {
});
test('TimingsCallback exceptions are caught', () {
FlutterErrorDetails errorCaught;
FlutterErrorDetails? errorCaught;
FlutterError.onError = (FlutterErrorDetails details) {
errorCaught = details;
};
SchedulerBinding.instance.addTimingsCallback((List<FrameTiming> timings) {
SchedulerBinding.instance!.addTimingsCallback((List<FrameTiming> timings) {
throw Exception('Test');
});
window.onReportTimings(<FrameTiming>[]);
expect(errorCaught.exceptionAsString(), equals('Exception: Test'));
window.onReportTimings!(<FrameTiming>[]);
expect(errorCaught!.exceptionAsString(), equals('Exception: Test'));
});
test('currentSystemFrameTimeStamp is the raw timestamp', () {
Duration lastTimeStamp;
Duration lastSystemTimeStamp;
late Duration lastTimeStamp;
late Duration lastSystemTimeStamp;
void frameCallback(Duration timeStamp) {
expect(timeStamp, scheduler.currentFrameTimeStamp);
@ -198,3 +196,14 @@ void main() {
expect(lastSystemTimeStamp, const Duration(seconds: 8));
});
}
class DummyTimer implements Timer {
@override
void cancel() {}
@override
bool get isActive => false;
@override
int get tick => 0;
}

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/scheduler.dart';
@Deprecated('scheduler_tester is not compatible with dart:async') // ignore: flutter_deprecation_syntax (see analyze.dart)
@ -12,6 +10,6 @@ class Future { } // so that people can't import us and dart:async
void tick(Duration duration) {
// We don't bother running microtasks between these two calls
// because we don't use Futures in these tests and so don't care.
SchedulerBinding.instance.handleBeginFrame(duration);
SchedulerBinding.instance.handleDrawFrame();
SchedulerBinding.instance!.handleBeginFrame(duration);
SchedulerBinding.instance!.handleDrawFrame();
}

View File

@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
@ -27,14 +25,14 @@ void main() {
expect(ticker.isActive, isTrue);
expect(tickCount, equals(0));
FlutterError error;
FlutterError? error;
try {
ticker.start();
} on FlutterError catch (e) {
error = e;
}
expect(error, isNotNull);
expect(error.diagnostics.length, 3);
expect(error!.diagnostics.length, 3);
expect(error.diagnostics.last, isA<DiagnosticsProperty<Ticker>>());
expect(
error.toStringDeep(),
@ -93,7 +91,7 @@ void main() {
});
testWidgets('Ticker control test', (WidgetTester tester) async {
Ticker ticker;
late Ticker ticker;
void testFunction() {
ticker = Ticker((Duration _) { });
@ -107,7 +105,7 @@ void main() {
testWidgets('Ticker can be sped up with time dilation', (WidgetTester tester) async {
timeDilation = 0.5; // Move twice as fast.
Duration lastDuration;
late Duration lastDuration;
void handleTick(Duration duration) {
lastDuration = duration;
}
@ -123,7 +121,7 @@ void main() {
testWidgets('Ticker can be slowed down with time dilation', (WidgetTester tester) async {
timeDilation = 2.0; // Move half as fast.
Duration lastDuration;
late Duration lastDuration;
void handleTick(Duration duration) {
lastDuration = duration;
}
@ -150,8 +148,8 @@ void main() {
expect(ticker.isActive, isTrue);
expect(tickCount, equals(0));
final ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused');
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) { });
final ByteData? message = const StringCodec().encodeMessage('AppLifecycleState.paused');
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', message, (_) { });
expect(ticker.isTicking, isFalse);
expect(ticker.isActive, isTrue);
@ -159,8 +157,8 @@ void main() {
});
testWidgets('Ticker can be created before application unpauses', (WidgetTester tester) async {
final ByteData pausedMessage = const StringCodec().encodeMessage('AppLifecycleState.paused');
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', pausedMessage, (_) { });
final ByteData? pausedMessage = const StringCodec().encodeMessage('AppLifecycleState.paused');
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', pausedMessage, (_) { });
int tickCount = 0;
void handleTick(Duration duration) {
@ -178,8 +176,8 @@ void main() {
expect(tickCount, equals(0));
expect(ticker.isTicking, isFalse);
final ByteData resumedMessage = const StringCodec().encodeMessage('AppLifecycleState.resumed');
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', resumedMessage, (_) { });
final ByteData? resumedMessage = const StringCodec().encodeMessage('AppLifecycleState.resumed');
await ServicesBinding.instance!.defaultBinaryMessenger.handlePlatformMessage('flutter/lifecycle', resumedMessage, (_) { });
await tester.pump(const Duration(milliseconds: 10));