LibraryGenerator class
Generates the library code containing extension methods, accessor methods, initialization functions, and module implementations for a set of dependencies.
- Mixed-in types
Constructors
-
LibraryGenerator({required List<
DependencyConfig> dependencies, required String initializerName, Uri? targetFile, bool asExtension = false, bool generateAccessors = false, String? microPackageName, Set<ExternalModuleConfig> microPackagesModulesBefore = const {}, Set<ExternalModuleConfig> microPackagesModulesAfter = const {}, bool usesConstructorCallback = false, bool allowMultipleRegistrations = false}) - Default constructor
Properties
- allowMultipleRegistrations → bool
-
Allows multiple registrations of the same type within this library, 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
- generateAccessors → bool
-
Creates an instance of LibraryGenerator with the provided configuration parameters, including the dependencies
to register, the initializer name, and micro-package module chaining information.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initializerName → String
-
The name of the initializer method to generate for the root scope, which will be called to register dependencies in GetIt.
final
- microPackageName → String?
-
The name of the micro-package module being generated, if applicable. If null, this library is not a micro-package module.
final
-
microPackagesModulesAfter
→ Set<
ExternalModuleConfig> -
The sets of external modules that should be initialized before and after registering the dependencies in this library,
used for micro-package module chaining. The
microPackagesModulesBeforeset contains modules that should be initialized before the dependencies in this library, while themicroPackagesModulesAfterset contains modules that should be initialized after. These sets are used to generate the appropriate initialization code in the generated library.final -
microPackagesModulesBefore
→ Set<
ExternalModuleConfig> -
The sets of external modules that should be initialized before and after registering the dependencies in this library,
used for micro-package module chaining. The
microPackagesModulesBeforeset contains modules that should be initialized before the dependencies in this library, while themicroPackagesModulesAfterset contains modules that should be initialized after. These sets are used to generate the appropriate initialization code in the generated library.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- targetFile → Uri?
-
The target file URI for resolving imports, which can be used to generate relative import paths.
final
- usesConstructorCallback → bool
-
The name of the initializer method to generate for the root scope, which will be called to register dependencies in GetIt.
final
Methods
-
generate(
) → Library - Generates the main library containing scopes, initializers, accessors, and modules.
-
generateAccessorMethods(
List< Method> extMethods) → void - Generates type-safe accessor methods for each dependency that is not from a module. These accessors can be called directly on the GetIt instance.
-
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