withLifecycle method

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

Attaches this ticker to a RaiiLifecycleAware object for automatic cleanup.

The ticker will be stopped and disposed when the lifecycle is disposed.

Implementation

Ticker withLifecycle(
  RaiiLifecycleAware lifecycleAware, {
  String? debugLabel,
}) {
  RaiiDisposeable.withLifecycle(
    lifecycleAware,
    dispose: () {
      stop();
      dispose();
    },
    debugLabel: debugLabel,
  );

  return this;
}