listen method

  1. @override
EventStreamSubscription<T> listen(
  1. void onData(
    1. T event
    )?, {
  2. Function? onError,
  3. void onDone()?,
  4. bool? cancelOnError = false,
  5. int priority = 0,
})
override

Adds a subscription to this stream that processes the event during the target or bubbling phase.

In contrast, the capture method processes the event during the capture phase.

On each data event from this stream, the subscriber's onData handler is called.

The priority level of the event listener can be specified. The higher the number, the higher the priority. All listeners with priority n are processed before listeners of priority n-1. If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.

Note: The onError and onDone handlers and cancelOnError are not used as the stream has no errors and is never done.

Implementation

@override
EventStreamSubscription<T> listen(void Function(T event)? onData,
        {Function? onError,
        void Function()? onDone,
        bool? cancelOnError = false,
        int priority = 0}) =>
    _subscribe(onData, false, priority);