useStreamController<T> method

StreamController<T> useStreamController<T>({
  1. void onListen()?,
  2. void onPause()?,
  3. void onResume()?,
  4. FutureOr<void> onCancel()?,
  5. bool sync = false,
})

Creates and automatically disposes a StreamController.

Implementation

StreamController<T> useStreamController<T>({
  void Function()? onListen,
  void Function()? onPause,
  void Function()? onResume,
  FutureOr<void> Function()? onCancel,
  bool sync = false,
}) {
  final state = stateOf(
    () => StreamController<T>(
      onListen: onListen,
      onPause: onPause,
      onResume: onResume,
      onCancel: onCancel,
      sync: sync,
    ),
    onDispose: (e) => e.close(),
  );

  return state.value;
}