singleCallbackPort<P> function
SendPort
singleCallbackPort<P>(
- void callback(
- P? response
- Duration? timeout,
- P? timeoutValue,
Create a SendPort that accepts only one message.
The callback function is called once, with the first message
received by the receive port.
All further messages are ignored.
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 callback function
is called once with the timeoutValue instead.
If the received value is not a T, it will cause an uncaught
asynchronous error in the current zone.
Returns the SendPort expecting the single message.
Equivalent to:
(new ReceivePort()
..first.timeout(duration, () => timeoutValue).then(callback))
.sendPort
Implementation
SendPort singleCallbackPort<P>(void Function(P? response) callback,
{Duration? timeout, P? timeoutValue}) =>
singleCallbackPortWithTimeout(
callback,
timeoutValue: timeoutValue,
timeout: timeout,
);