Completer<T> constructor Null safety
Creates a new completer.
The general workflow for creating a new future is to 1) create a new completer, 2) hand out its future, and, at a later point, 3) invoke either complete or completeError.
The completer completes the future asynchronously. That means that callbacks registered on the future are not called immediately when complete or completeError is called. Instead the callbacks are delayed until a later microtask.
Example:
var completer = new Completer();
handOut(completer.future);
later: {
completer.complete('completion value');
}
Implementation
factory Completer() => new _AsyncCompleter<T>();