updateShouldNotifyDependent method

  1. @override
bool updateShouldNotifyDependent(
  1. covariant SharedValueInheritedModel oldWidget,
  2. Set<SharedValue> dependencies
)
override

Return true if the changes between this model and oldWidget match any of the dependencies.

Implementation

@override
bool updateShouldNotifyDependent(
  SharedValueInheritedModel oldWidget,
  Set<SharedValue> dependencies,
) {
  for (SharedValue sharedValue in dependencies) {
    // Compare the nonce value of this SharedValue,
    // with an older nonce value of the same SharedValue object.
    //
    // If the nonce values are not same,
    // rebuild the widget
    if (sharedValue.nonce != oldWidget.stateNonceMap[sharedValue]) {
      return true;
    }
  }
  return false;
}