autoDispose<T> method
T
autoDispose<T>(
- T object
inherited
Registers object for automatic cleanup when the controller closes.
Supports:
- LxReactive (closes the reactive)
- StreamSubscription (cancels subscription)
- Timer (cancels timer)
- Sink (closes sink)
- Anything with a
dispose(),close(), orcancel()method.
Returns the object to allow inline use during initialization.
// Example usage:
late final sub = autoDispose(stream.listen((_) {}));
Implementation
T autoDispose<T>(T object) => own(object);