onStop method

  1. @override
Future<bool> onStop()
override

Callback when this executor is stopped. Returns true if successfully stopped, false otherwise.

Implementation

@override
Future<bool> onStop() async {
  if (timer != null) 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;
}