getManagedDelayedFuture<T> method

  1. @mustCallSuper
  2. @override
Future<T> getManagedDelayedFuture <T>(Duration duration, T callback())
@mustCallSuper, override

Creates a Future that will complete, with the value returned by callback, after the given amount of time has elapsed.

If the object is disposed before the time has elapsed the future will complete with an ObjectDisposedException error.


Future<T> getManagedDelayedFuture<T>(Duration duration, T callback()) {
      'getManagedDelayedFuture', 'duration', 'callback', duration, callback);
  var completer = new Completer<T>();
  var timer =
      new _ObservableTimer(duration, () => completer.complete(callback()));
  var disposable = new ManagedDisposer(() async {
    completer.completeError(new ObjectDisposedException());
  timer.didConclude.then((Null _) {
    // ignore: deprecated_member_use
    if (!isDisposedOrDisposing) {
  return completer.future;