ComputeCallback<Q, R> typedef Null safety

ComputeCallback<Q, R> = FutureOr<R> Function(Q message)

Signature for the callback passed to compute.

The compute method accepts the following parameters:

  • Q is the type of the message that kicks off the computation.
  • R is the type of the value returned.

There are limitations on the values that can be sent and received to and from isolates. These limitations constrain the values of Q and R that are possible. See the discussion at SendPort.send.

The same limitations apply to any errors generated by the computation.

Instances of ComputeCallback must be functions that can be sent to an isolate. Qualifying functions include:

  • top-level functions
  • static methods
  • closures that only capture objects that can be sent to an isolate

Using closures must be done with care. Due to dart-lang/sdk#36983 a closure may capture objects that, while not directly used in the closure itself, may prevent it from being sent to an isolate.

The compute method accepts the following parameters:

  • Q is the type of the message that kicks off the computation.
  • R is the type of the value returned.

There are limitations on the values that can be sent and received to and from isolates. These limitations constrain the values of Q and R that are possible. See the discussion at SendPort.send.

The same limitations apply to any errors generated by the computation.

Implementation

typedef ComputeCallback<Q, R> = FutureOr<R> Function(Q message);