register function

void register(
  1. Object key,
  2. Object value, {
  3. ScopeExitCallback? onScopeExit,
})

Register a new object into the current service scope using the given key.

If onScopeExit is provided, it will be called when the service scope ends.

The registered on-scope-exit functions are executed in reverse registration order.

Implementation

void register(Object key, Object value, {ScopeExitCallback? onScopeExit}) {
  var serviceScope = _serviceScope;
  if (serviceScope == null) {
    throw StateError('Not running inside a service scope zone.');
  }
  serviceScope.register(key, value, onScopeExit: onScopeExit);
}