createWithArgument<T, R> static method
Work<R>
createWithArgument<T, R>(
- T argument,
- FutureOr<
R> computation(- T arg
- CancellationToken? token,
Returns an instance of Work depending on the platform (for
the native platform it is IsolatedContext, for the web platform it
is ZonedContext).
Parameters:
argument: Argument to pass to thecomputationfunction.computation: A function that represents a computation.token: Cancellation token used for canceling the execution of computation.
If the token parameter is specified, it can be retrieved in the
computation body by calling Task.token.
Token-based cancellation is a very flexible cancellation method,
implemented solely based on the cancellation request processing logic.
Implementation
static Work<R> createWithArgument<T, R>(
T argument,
FutureOr<R> Function(T arg) computation, {
CancellationToken? token,
}) {
return _createPlatformSpecificWork(() => computation(argument),
token: token);
}