ControllableFuture
- Cancel the
Future
final controllable = ControllableFuture(() async {
/// some asynchronous code here,
}, onCancel: () {
// return an alternate value
});
// to wait
await controllable.future;
// to cancel
controllable.cancel();
Why not CancelableOperaion
in package:async
?
It does not step out of the Future
on cancellation. It just ignores the Future
.
But this package actually cancels it.
Libraries
- future_ext
- Set of libraries to control Futures.