canUpdate method

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==.

If the widgets have no key (their key is null), then they are considered a match if they have the same type, even if their children are completely different.

Implementation

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