of abstract method

T of(
  1. BuildContext context, {
  2. bool defaultToGlobal = false,
})

Obtain the state from the nearest InheritedWidget inserted using inherited.

The BuildContext used, will be registered so that when this Injected model emits a notification, the Element related the the BuildContext will rebuild.

If you want to obtain the state without registering use the call method.

myModel.of(context); // Will return the state and register the BuildContext.
myModel(context); // Will return the Injected model and do not register the BuildContext.

Implementation

T of(BuildContext context, {bool defaultToGlobal = false});