setActiveScope function

EffectScopeReactiveNode? setActiveScope([
  1. EffectScopeReactiveNode? scope
])

Sets the ambient EffectScopeReactiveNode and returns the previous scope.

Parameters:

  • scope: Scope that should own subsequently created effects

Example:

final rootScope = CustomEffectScope();
final prevScope = setActiveScope(rootScope);
try {
  rootScope.flags |= ReactiveFlags.watching;
} finally {
  setActiveScope(prevScope);
}

Implementation

@pragma("vm:prefer-inline")
@pragma("wasm:prefer-inline")
@pragma("dart2js:prefer-inline")
EffectScopeReactiveNode? setActiveScope([EffectScopeReactiveNode? scope]) {
  final prevScope = activeScope;
  activeScope = scope;
  return prevScope;
}