onPause method
Called by pause. Returns true if successfully paused.
If false, the state is not changed.
Implementation
@override
Future<bool> onPause() async {
timer?.cancel();
// check if there are some buffered data that needs to be collected before pausing
try {
Measurement? measurement = await getMeasurement();
if (measurement != null) addMeasurement(measurement);
} catch (error) {
addError(error);
}
return true;
}