AwaitableTimer constructor
Implementation
AwaitableTimer(Duration d, FutureOr Function() callback) {
_timer = Timer(d, () async {
try {
_completer.complete(await callback());
} on StateError {
// No-op, as [Future] is allowed to be completed.
} catch (e, stackTrace) {
try {
_completer.completeError(e, stackTrace);
} on StateError {
// [_completer]'s future is allowed to be competed at this point.
Log.error(
'Callback completed with the following exception: $e',
'$runtimeType',
);
}
}
});
}