updateShouldNotify method

  1. @override
bool updateShouldNotify(
  1. covariant Scope oldWidget
)
override

Whether the framework should notify widgets that inherit from this widget.

When this widget is rebuilt, sometimes we need to rebuild the widgets that inherit from this widget but sometimes we do not. For example, if the data held by this widget is the same as the data held by oldWidget, then we do not need to rebuild the widgets that inherited the data held by oldWidget.

The framework distinguishes these cases by calling this function with the widget that previously occupied this location in the tree as an argument. The given widget is guaranteed to have the same runtimeType as this object.

Implementation

@override
bool updateShouldNotify(Scope oldWidget) {
  return scope != oldWidget.scope;
}