RaiiListenableListener<T extends Listenable>.withLifecycle constructor
RaiiListenableListener<T extends Listenable>.withLifecycle (
- RaiiLifecycleAware lifecycleAware, {
- required T listenable,
- required VoidCallback onListen,
- 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);
}