of static method

EasyModule? of(
  1. BuildContext context, {
  2. bool listen = false,
})

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 tree
  • listen: 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

static EasyModule? of(BuildContext context, {bool listen = false}) {
  return EasyModuleInheritedWidget.of(context, listen: listen)?.module;
}