DireContainer class
The main dependency injection container for Dire DI
This container provides Spring-like dependency injection capabilities with code generation support for Flutter compatibility.
Example usage:
final container = DireContainer();
await container.scan(); // Uses generated code for scanning
final userService = container.get<UserService>();
Constructors
Properties
- context → InjectionContext
-
Gets the injection context
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addProperties(
Map< String, String> properties) → void - Adds properties to the container
-
clearSingletons(
) → void - Clears all singleton instances (useful for testing)
-
contains<
T extends Object> ([String? qualifier]) → bool - Checks if a bean of the specified type exists
-
destroy(
) → void - Destroys the container and cleans up resources
-
get<
T extends Object> ([String? qualifier]) → T - Gets a bean of the specified type
-
getAll<
T extends Object> () → List< T> - Gets all beans of the specified type
-
getBeanNames<
T extends Object> ([String? qualifier]) → List< String> - Gets bean names of the specified type
-
getByName(
String name) → Object - Gets a bean by name
-
getProperty(
String key) → String? - Gets a property value
-
getPropertyOrDefault(
String key, String defaultValue) → String - Gets a property value with default
-
markInitialized(
) → void - Internal method to mark container as initialized
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
register<
T extends Object> (T factory(), {String? name, String? qualifier, ScopeType scope = ScopeType.singleton, List< String> profiles = const [], bool isPrimary = false}) → void - Manually registers a bean definition
-
registerInstance<
T extends Object> (T instance, {String? name, String? qualifier, List< String> profiles = const [], bool isPrimary = false}) → void - Registers an existing instance as a singleton bean
-
scan(
[List< String> ? packagePatterns]) → Future<void> - Scans for components and registers them automatically
-
setActiveProfiles(
List< String> profiles) → void - Sets active profiles
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited