This repository was archived by the owner on Feb 22, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,7 @@ class _Resampler {
180
180
}
181
181
_resamplers.clear ();
182
182
_frameTime = Duration .zero;
183
+ _timer? .cancel ();
183
184
}
184
185
185
186
void _onSampleTimeChanged () {
Original file line number Diff line number Diff line change @@ -123,4 +123,20 @@ void main() {
123
123
expect (events[3 ].timeStamp, currentTestFrameTime () + kSamplingOffset);
124
124
expect (events[3 ], isA <PointerUpEvent >());
125
125
});
126
+
127
+ testWidgets ('Timer should be canceled when resampling stopped' , (WidgetTester tester) async {
128
+ // A timer will be started when event's timeStamp is larger than sampleTime.
129
+ final ui.PointerDataPacket packet = ui.PointerDataPacket (
130
+ data: < ui.PointerData > [
131
+ ui.PointerData (
132
+ timeStamp: Duration (microseconds: DateTime .now ().microsecondsSinceEpoch),
133
+ ),
134
+ ],
135
+ );
136
+ GestureBinding .instance.resamplingEnabled = true ;
137
+ ui.window.onPointerDataPacket !(packet);
138
+
139
+ // Expected to stop resampling, but the timer keeps active if _timer?.cancel() not be called.
140
+ GestureBinding .instance.resamplingEnabled = false ;
141
+ });
126
142
}
You can’t perform that action at this time.
0 commit comments