ZonedWork<T> class

A ZonedWork is an operation for executing a computation inside the Zone container with the possibility of externally controlled termination.

⚠️ Warning:
When using ZonedWork, the following limitation should be taken into account.
Because ZonedWork runs in a separate zone with its own uncaught errors handler ZoneSpecification.handleUncaughtError due to limitations of the Dart SDK, when using such a handler, in some cases, errors from the parent zone may not leave the parent zone and may lead to the fact that it will be physically impossible to catch them (and shut down the Zone correctly).

More detailed information can be found here:

Implemented types

Constructors

ZonedWork(FutureOr<T> computation(), {CancellationToken? token})
Creates an instance of ZonedWork.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() Future<T>
Executes the computation and returns the computation result (or throws the exception), or throws the CancellationException exception.
override
terminate({bool force = false}) → void
Requests to terminate the execution of a computation.
override
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

withArgument<T, R>(T argument, FutureOr<R> computation(T arg), {CancellationToken? token}) ZonedWork<R>
Creates an instance of ZonedWork.