runEffectScope method

void runEffectScope(
  1. EffectScope scope,
  2. void fn()
)

Executes a function within an effect scope while tracking dependencies.

This method:

  1. Saves the current active scope
  2. Sets the provided scope as active
  3. Starts dependency tracking for the scope
  4. Runs the provided function
  5. Restores the previous active scope
  6. Ends dependency tracking

scope The effect scope to run within fn The function to execute in the scope

Implementation

void runEffectScope(EffectScope scope, void Function() fn) {
  final prevSub = activeScope;
  activeScope = scope;
  startTracking(scope);
  try {
    fn();
  } finally {
    activeScope = prevSub;
    endTracking(scope);
  }
}