SafeCompleter<T extends Object> class

A wrapper around Dart's Completer that prevents it from being completed more than once.

It provides an API for resolving a value and safely accessing the result via a Resolvable. This is useful for managing one-off asynchronous operations where multiple callers might attempt to set the result.

Isolate sendability (current state)

SafeCompleter is not yet sendable through SendPort: it wraps a dart:async Completer, which is bound to the isolate that created it. Sending a SafeCompleter will throw at runtime. A future phase will replace the internal completer with a conditional SendPort broker on VM platforms so the completer itself can travel between isolates. Web platforms have no isolates, so the current implementation is appropriate there.

In the meantime, ship the result instead: await the completer locally, then send the resulting Result (which is fully sendable) to the destination isolate.

Constructors

SafeCompleter()

Properties

hashCode int
The hash code for this object.
no setterinherited
isCompleted bool
Indicates whether the completer has been claimed for completion.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

complete(FutureOr<T> value) Resolvable<T>
A convenience method to complete with a direct value or future.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolvable() Resolvable<T>
Returns a Resolvable that provides access to the completer's result.
resolve(Resolvable<T> resolvable) Resolvable<T>
Safely resolves the completer with the outcome of a Resolvable.
toString() String
A string representation of this object.
inherited
transf<R extends Object>([R noFutures(T e)?]) SafeCompleter<R>
Creates a new SafeCompleter by transforming the future value of this one.

Operators

operator ==(Object other) bool
The equality operator.
inherited