How to use GetIt scopes with injectable
masterYou can use GetIt scopes to group related dependencies that should only be initialized and disposed of when needed.
To register a dependency within a specific scope, annotate it with @Scope('scope-name') or use the scope property in @Injectable.
Dependencies tagged with a scope will be generated inside a separate initialization method/extension specific to that scope. Because scope-init methods may return a Future if they have pre-resolved dependencies, you should await them.
To use a scope, call the generated extension or method on your GetIt instance.
// 1. Annotate the dependency with a scope
@Injectable(scope: 'auth')
class AuthController {}
// 2. Initialize the scope when needed
// Using extensions
await getIt.initAuthScope();
// OR using methods
await initAuthScope(getIt);