listen method Null safety

LightSubscription<T> listen(
  1. void onData(
    1. T event
    ),
  2. {Function? onError,
  3. void onDone(
      )?,
    1. bool? cancelOnError}
    )

    Implementation

    LightSubscription<T> listen(void Function(T event) onData,
        {Function? onError, void Function()? onDone, bool? cancelOnError}) {
      final subs = LightSubscription<T>(
        removeSubscription,
        onPause: onPause,
        onResume: onResume,
        onCancel: onCancel,
      )
        ..onData(onData)
        ..onError(onError)
        ..onDone(onDone)
        ..cancelOnError = cancelOnError;
      addSubscription(subs);
      onListen?.call();
      return subs;
    }