Future<T> constructor
- FutureOr<
T> computation(
Creates a future containing the result of calling computation
asynchronously with Timer.run.
If the result of executing computation
throws, the returned future is
completed with the error.
If the returned value is itself a Future, completion of the created future will wait until the returned future completes, and will then complete with the same result.
If a non-future value is returned, the returned future is completed with that value.
Implementation
factory Future(FutureOr<T> computation()) {
_Future<T> result = new _Future<T>();
Timer.run(() {
try {
result._complete(computation());
} catch (e, s) {
_completeWithErrorCallback(result, e, s);
}
});
return result;
}