dependOnInheritedComponentOfExactType<T extends InheritedComponent> method

  1. @override
T? dependOnInheritedComponentOfExactType<T extends InheritedComponent>({
  1. Object? aspect,
})
override

Obtains the nearest component of the given type T, which must be the type of a concrete InheritedComponent subclass, and registers this build context with that component such that when that component changes (or a new component of that type is introduced, or the component goes away), this build context is rebuilt so that it can obtain new values from that component.

This is typically called implicitly from of() static methods, e.g. Router.of.

The aspect parameter is only used when T is an InheritedComponent subclasses that supports partial updates. It specifies what "aspect" of the inherited component this context depends on.

Implementation

@override
T? dependOnInheritedComponentOfExactType<T extends InheritedComponent>({Object? aspect}) {
  final InheritedElement? ancestor = _inheritedElements == null ? null : _inheritedElements![T];
  if (ancestor != null) {
    return dependOnInheritedElement(ancestor, aspect: aspect) as T;
  }
  _hadUnsatisfiedDependencies = true;
  return null;
}