From d8f2d018ad383112f6b97600c2366acf9b69be2c Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 27 Apr 2016 15:51:20 -0700 Subject: [PATCH] Expose dispatchDependencyChanged in InheritedWidget (#3580) Some inherited widgets want to call this function direction, for example to notify children when a mutable model object changes. Exposing this function to subclasses of InheritedWidget is clear then forcing them to compute updateShouldNotify for mutable model objects. --- packages/flutter/lib/src/widgets/framework.dart | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index fb0388edf5..88412b4021 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -1738,6 +1738,16 @@ class InheritedElement extends _ProxyElement { void notifyDescendants(InheritedWidget oldWidget) { if (!widget.updateShouldNotify(oldWidget)) return; + dispatchDependenciesChanged(); + } + + /// Notifies all dependent elements that this inherited widget has changed. + /// + /// [InheritedElement] calls this function if [InheritedWidget.updateShouldNotify] + /// returns true. Subclasses of [InheritedElement] might wish to call this + /// function at other times if their inherited information changes outside of + /// the build phase. + void dispatchDependenciesChanged() { final Type ourRuntimeType = widget.runtimeType; for (Element dependant in _dependents) { dependant.dependenciesChanged(ourRuntimeType);