setDependencies method
Sets the value returned by getDependencies value for dependent.
Each dependent element is mapped to a single object value which represents how the element depends on this InheritedElement. The updateDependencies method sets this value to null by default so that dependent elements are rebuilt unconditionally.
Subclasses can manage these values with updateDependencies so that they can selectively rebuild dependents in notifyDependent.
This method is typically only called in overrides of updateDependencies.
For example, InheritedModelElement.updateDependencies calls this method
to register the initial dependency value for a dependent, or to replace
it with an unconditional dependency, and otherwise mutates the existing
Set returned by getDependencies in-place without calling this method
again if the same dependent has already been registered by a previous
call to updateDependencies.
See also:
- updateDependencies, which is called each time a dependency is created with dependOnInheritedWidgetOfExactType.
- getDependencies, which returns the current value for a dependent element.
- notifyDependent, which can be overridden to use a dependent's getDependencies 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 setDependencies(Element dependent, Object? value) {
_dependents[dependent] = value;
}