RaiiListenableListener<T extends Listenable>.withLifecycle constructor

RaiiListenableListener<T extends Listenable>.withLifecycle(
  1. RaiiLifecycleAware lifecycleAware, {
  2. required T listenable,
  3. required VoidCallback onListen,
  4. String? debugLabel,
})

Creates a RaiiListenableListener and attaches it to the provided lifecycleAware.

The listener will be automatically added during initialization and removed during disposal, ensuring proper cleanup of event handlers.

Implementation

RaiiListenableListener.withLifecycle(
  RaiiLifecycleAware lifecycleAware, {
  required this.listenable,
  required this.onListen,
  this.debugLabel,
}) {
  lifecycleAware.registerLifecycle(this);
}