listen method

StreamSubscription listen(
  1. void onData(
    1. dynamic message
    ), {
  2. Function? onError,
  3. void onDone()?,
  4. bool? cancelOnError,
})

Returns a StreamSubscription which returns messages from the connected HandledIsolate instance.

Note that onError and cancelOnError are ignored since a ReceivePort will never receive an error.

The onDone handler will be called when the stream closes. The stream closes when close is called on inPort.

Implementation

StreamSubscription<dynamic> listen(
  void Function(dynamic message) onData, {
  Function? onError,
  void Function()? onDone,
  bool? cancelOnError,
}) =>
    _port.listen(
      (var message) => _listenResponse(message, onData),
      onError: onError,
      onDone: onDone,
      cancelOnError: cancelOnError,
    );