CarburetorDynamicModule<Module_ extends CarburetorModule> class sealed

A CarburetorModule wrapper that facilitates incremental migration from a runtime dependency injection system to Carburetor's build-time approach.

During migration, some dependencies may not yet be registered in a Carburetor-generated module. CarburetorDynamicModule allows those dependencies to be provided at runtime by calling set, while all already-migrated dependencies are resolved normally through the underlying module. Once all dependencies have been migrated, this wrapper can be removed and the generated module used directly.

This class is also useful in tests to override specific dependencies without replacing the entire module.

Example:

// During migration: override a dependency not yet handled by the module.
final dynamic = CarburetorDynamicModule(appModule);
dynamic.set<LegacyService>(legacyServiceInstance);

final service = dynamic.get<LegacyService>(); // returns legacyServiceInstance
final other   = dynamic.get<MigratedService>(); // resolved by appModule
Implemented types
Implementers

Constructors

CarburetorDynamicModule(Module_ module)
Wraps module in a CarburetorDynamicModule that delegates all non-overridden resolutions to module.
const
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
module → Module_
The underlying module that handles non-overridden dependency resolutions.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

get<T extends Object>({String? name}) → T
Returns the dependency of type T, using the registered override when one exists, or falling back to module.
override
getAsync<T extends Object>({String? name}) Future<T>
Returns the dependency of type T asynchronously, using the registered override when one exists, or falling back to module.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
remove<T extends Object>({String? name}) → void
Removes the override for type T (and the optional name).
set<T extends Object>(T value, {String? name}) → void
Registers value as the override for type T.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited