updateDependencies method Null safety

  1. @protected
void updateDependencies(
  1. Element dependent,
  2. Object? aspect
)

Called by dependOnInheritedWidgetOfExactType when a new dependent is added.

Each dependent element can be mapped to a single object value with setDependencies. This method can lookup the existing dependencies with getDependencies.

By default this method sets the inherited dependencies for dependent to null. This only serves to record an unconditional dependency on dependent.

Subclasses can manage their own dependencies values so that they can selectively rebuild dependents in notifyDependent.

See also:

  • getDependencies, which returns the current value for a dependent element.
  • setDependencies, which sets the value for a dependent element.
  • notifyDependent, which can be overridden to use a dependent's dependencies value to decide if the dependent needs to be rebuilt.
  • InheritedModel, which is an example of a class that uses this method to manage dependency values.

Implementation

@protected
void updateDependencies(Element dependent, Object? aspect) {
  setDependencies(dependent, null);
}