InitMethodGenerator class
Generates the initialization method for a specific scope (or the root scope) to register all dependencies within that scope into GetIt.
- Mixed-in types
Constructors
-
InitMethodGenerator({required List<
DependencyConfig> scopeDependencies, required DependencyList allDependencies, required String initializerName, Uri? targetFile, bool asExtension = false, String? scopeName, bool isMicroPackage = false, Set<ExternalModuleConfig> microPackagesModulesBefore = const {}, Set<ExternalModuleConfig> microPackagesModulesAfter = const {}, bool usesConstructorCallback = false, bool allowMultipleRegistrations = false}) - Default constructor
Properties
- allDependencies → DependencyList
-
All dependencies across scopes, used for determining module overrides and async dependencies.
final
- allowMultipleRegistrations → bool
-
Allows multiple registrations of the same type within this scope, which can be useful for certain testing scenarios or when using named instances. When true, it enables the
enableRegisteringMultipleInstancesOfOneTypeflag on GetIt.final - asExtension → bool
-
A flag indicating whether to generate extension methods for registration or standalone functions.
final
- dependencies ↔ DependencyList
-
A list of dependencies to be registered, wrapped in a DependencyList for additional functionality.
getter/setter pairoverride-getter
- hashCode → int
-
The hash code for this object.
no setterinherited
- initializerName → String
-
The name of the initializer method to generate (e.g., `init
final
- isMicroPackage → bool
-
Indicates whether this initializer is being generated for a micro-package module, which affects the return type and method signature.
final
-
microPackagesModulesAfter
→ Set<
ExternalModuleConfig> -
The set of external modules that should be initialized before registering the dependencies in this scope, used for micro-package module chaining.
final
-
microPackagesModulesBefore
→ Set<
ExternalModuleConfig> -
The set of external modules that should be initialized before registering the dependencies in this scope, used for micro-package module chaining.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scopeName → String?
-
The name of the scope for which this initializer is being generated, or null for the root scope.
final
- targetFile → Uri?
-
The target file URI for resolving imports, which can be used to generate relative import paths.
final
- usesConstructorCallback → bool
-
Indicates whether to wrap instance creation with a constructor callback, allowing for custom logic to be applied to all instances after construction.
final
Methods
-
buildLazyRegisterFun(
DependencyConfig dep) → Code - Builds the code expression for registering a lazy or factory dependency.
-
buildSingletonRegisterFun(
DependencyConfig dep) → Code - Builds the code expression for registering a singleton dependency.
-
generate(
) → Method - Generates the initialization method AST node.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited