Effect.withCleanup constructor

Effect.withCleanup(
  1. void fn(
    1. void (
      1. void ()
      )
    )
)

Creates an effect that can register cleanup callbacks for each run.

Registered callbacks run before the next execution and when the effect is disposed. This is useful for timers, stream subscriptions, and listeners.

Implementation

Effect.withCleanup(void Function(void Function(void Function())) fn)
    : _fn = null,
      _cleanupFn = fn {
  run();
}