onStart method

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

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

Implementation

@override
Future<bool> onStart() async {
  if (await requestPermissions()) {
    getMeasurement().then((measurement) {
      if (measurement != null) addMeasurement(measurement);
      // automatically stop this probe after it is done collecting the measurement
      Future.delayed(const Duration(seconds: 5), () => stop());
    }, onError: (Object error) => addError(error));

    return true;
  } else {
    return false;
  }
}