TickerRaiiExt extension

Extension for managing Ticker lifecycle.

This extension ensures both stopping and disposing of the ticker.

Example:

class MyWidgetState extends State<MyWidget>
    with TickerProviderStateMixin, RaiiStateMixin {
  late final ticker = Ticker(onTick)
    .withLifecycle(this, debugLabel: 'MyTicker');
}
on

Methods

withLifecycle(RaiiLifecycleAware lifecycleAware, {String? debugLabel}) Ticker

Available on Ticker, provided by the TickerRaiiExt extension

Attaches this ticker to a RaiiLifecycleAware object for automatic cleanup.