dependOnInheritedElement method

  1. @override
InheritedWidget dependOnInheritedElement(
  1. InheritedElement ancestor,
  2. {Object? aspect}

Registers this build context with ancestor such that when ancestor's widget changes this build context is rebuilt.

Returns ancestor.widget.

This method is rarely called directly. Most applications should use dependOnInheritedWidgetOfExactType, which calls this method after finding the appropriate InheritedElement ancestor.

All of the qualifications about when dependOnInheritedWidgetOfExactType can be called apply to this method as well.


InheritedWidget dependOnInheritedElement(InheritedElement ancestor, { Object? aspect }) {
  _dependencies ??= HashSet<InheritedElement>();
  ancestor.updateDependencies(this, aspect);
  return ancestor.widget as InheritedWidget;