singleResponseFuture<R> function
Creates a Future, and a SendPort that can be used to complete that future.
Calls action
with the response SendPort
, then waits for someone
to send a value on that port
The returned Future
is completed with the value sent on the port.
If action
throws, which it shouldn't,
the returned future is completed with that error.
Any return value of action
is ignored, and if it is asynchronous,
it should handle its own errors.
If timeout
is supplied, it is used as a limit on how
long it can take before the message is received. If a
message isn't received in time, the timeoutValue
used
as the returned future's value instead.
If you want a timeout on the returned future, it's recommended to
use the timeout
parameter, and not Future.timeout on the result.
The Future
method won't be able to close the underlying ReceivePort.
Implementation
Future<R?> singleResponseFuture<R>(
void Function(SendPort responsePort) action, {
Duration? timeout,
R? timeoutValue,
}) =>
singleResponseFutureWithTimeout(
action,
timeout: timeout,
timeoutValue: timeoutValue,
);