onPause method
Callback when this executor is paused. Returns true if successfully paused, false otherwise.
Implementation
@override
Future<bool> onPause() async {
// when pausing the audio sampling, stop recording and collect the datum
if (_isRecording) {
try {
await _stopAudioRecording();
Datum? data = await getDatum();
if (data != null) controller.add(data);
debug('Audio recording paused - sound file : $_soundFileName');
} catch (error) {
warning('An error occured trying to stop audio recording - $error');
controller.addError(error);
}
}
return true;
}