bool canUpdate(Widget oldWidget, Widget newWidget)

Whether the newWidget can be used to update an Element that currently has the oldWidget as its configuration.

An element that uses a given widget as its configuration can be updated to use another widget as its configuration if, and only if, the two widgets have runtimeType and key properties that are operator==.

Source

static bool canUpdate(Widget oldWidget, Widget newWidget) {
  return oldWidget.runtimeType == newWidget.runtimeType
      && oldWidget.key == newWidget.key;
}