run<T> method
Implementation
Future<T> run<T>(Future<T> Function() task) {
final completer = Completer<T>();
// The continuation never throws (errors are routed to [completer]), so the
// chain keeps flowing even after a task fails.
_tail = _tail.then((_) async {
try {
completer.complete(await task());
} catch (error, stack) {
completer.completeError(error, stack);
}
});
return completer.future;
}