dependOnInheritedWidget method

  1. @override
bool dependOnInheritedWidget(
  1. BuildContext? context
)
override

Set the specified widget (through its context) as a dependent of the InheritedWidget

Return false if not configured to use the InheritedWidget

Implementation

@override
bool dependOnInheritedWidget(BuildContext? context) {
  var depend = _useInherited && context != null;
  if (depend) {
    if (_inheritedElement == null) {
      _dependencies.add(context);
    } else {
      context.dependOnInheritedElement(_inheritedElement!);
    }
  } else {
    depend = super.dependOnInheritedWidget(context);
  }
  return depend;
}