EasyModule class abstract
A module is a class that contains the dependencies of a feature.
It can be used to register dependencies, imports, and other configurations. Each module represents a self-contained feature or component of the application.
Example:
class MyFeatureModule extends Module {
@override
List<Type> imports = [CoreModule];
@override
Future<void> registerBinds(InjectorRegister i) async {
i.addSingleton<MyService>(() => MyServiceImpl());
i.add<MyRepository>(() => MyRepositoryImpl());
}
}
- Inheritance
-
- Object
- ChangeNotifier
- EasyModule
- Implementers
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
imports
→ List<
Type> -
List of other module types that this module depends on.
no setter
- injector ↔ CustomAutoInjector?
-
The dependency injector for this module.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
dispose(
[void instanceCallback(dynamic)?]) → void -
Disposes of the module and its dependencies.
override
-
importsModule(
EasyModule module) → bool - Checks if this module imports another module.
-
init(
) → Future< CustomAutoInjector> - Initializes the module by creating an injector and registering dependencies.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
registerBinds(
InjectorRegister i) → FutureOr< void> - Registers dependencies for this module using the provided InjectorRegister.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
reset(
[void instanceCallback(dynamic)?]) → Future< void> - Resets the module by disposing of its dependencies and reinitializing it.
-
toString(
) → String -
A string representation of this object.
inherited
-
validateImports(
) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
disposeSingleton<
T extends Object> (BuildContext context) → T? -
Disposes a specific singleton of type
T
from the module. -
of(
BuildContext context, {bool listen = false}) → EasyModule? - Gets the current EasyModule instance from the widget tree.