withScope method

  1. @override
Spec<T> withScope(
  1. ScopeType type
)
override

Defines the type of scope this pod belongs to (e.g., singleton, prototype).

  • singleton: one shared instance across the container.
  • prototype: a new instance each time it is requested.

Example

spec.withScope(ScopeType.singleton);

Implementation

@override
Spec<T> withScope(ScopeType type) {
  _root.scope = ScopeDesign(
    type: type.name,
    isSingleton: type == ScopeType.SINGLETON,
    isPrototype: type == ScopeType.PROTOTYPE,
  );

  return this;
}