shouldUpdateWidget method

  1. @override
bool shouldUpdateWidget(
  1. covariant Widget oldWidget
)
inherited

Whether to update current widget.

Framework calls this method on new widget, when new widget matches with a old widget,to check whether old widget need to update. This method should contain the logic to compare new widget with old.

Diffing process will always call shouldUpdateWidget on child widgets of current widget even if shouldUpdateWidget return false. This means whatever diffing logic is present in this method, its scope should be limited to checking just the current widget. If a widget want to short-circuit diffing process(i.e no shouldUpdateWidget on child widgets) then it can override shouldUpdateWidgetChildren method.

Implementation

@override
bool shouldUpdateWidget(
  covariant oldWidget,
) {
  oldWidget as HTMLTableCellBase;

  return abbr != oldWidget.abbr ||
      rowSpan != oldWidget.rowSpan ||
      colSpan != oldWidget.colSpan ||
      headers != oldWidget.headers ||
      scope != oldWidget.scope ||
      super.shouldUpdateWidget(oldWidget);
}