of static method
- @Deprecated('Use EasyDI.of instead')
- BuildContext context, {
- bool listen = false,
override
Gets the current EasyModule instance from the widget tree.
This method searches up the widget tree for a EasyModuleInheritedWidget
and returns
its associated module. If no module is found, returns null.
Parameters:
context
: The build context used to find the module in the widget treelisten
: Whether to register the calling widget for module updates. If true, the widget will rebuild when the module changes. Defaults to false.
Returns:
- The closest EasyModule instance in the widget tree, or null if none is found.
Example:
final currentModule = Module.of(context);
if (currentModule != null) {
// Use the module
}
Implementation
@Deprecated('Use EasyDI.of instead')
static Module? of(BuildContext context, {bool listen = false}) {
return EasyModuleInheritedWidget.of(context, listen: listen)?.module as Module?;
}