inheritFromWidgetOfExactType method

  1. @Deprecated('Use dependOnInheritedWidgetOfExactType instead. ' 'This feature was deprecated after v1.12.1.')
  2. @override
InheritedWidget inheritFromWidgetOfExactType (Type targetType, { Object aspect })
@Deprecated('Use dependOnInheritedWidgetOfExactType instead. ' 'This feature was deprecated after v1.12.1.'), override

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

This method is deprecated. Please use dependOnInheritedWidgetOfExactType instead.

Implementation

@Deprecated(
  'Use dependOnInheritedWidgetOfExactType instead. '
  'This feature was deprecated after v1.12.1.'
)
@override
InheritedWidget inheritFromWidgetOfExactType(Type targetType, { Object aspect }) {
  assert(_debugCheckStateIsActiveForAncestorLookup());
  final InheritedElement ancestor = _inheritedWidgets == null ? null : _inheritedWidgets[targetType];
  if (ancestor != null) {
    assert(ancestor is InheritedElement);
    return inheritFromElement(ancestor, aspect: aspect);
  }
  _hadUnsatisfiedDependencies = true;
  return null;
}