didUpdateComponent method

  1. @override
void didUpdateComponent(
  1. covariant Router oldComponent
)

Called whenever the component configuration changes.

If the parent component rebuilds and request that this location in the tree update to display a new component with the same runtimeType and Component.key, the framework will update the component property of this State object to refer to the new component and then call this method with the previous component as an argument.

Override this method to respond when the component changes (e.g., to start implicit animations).

The framework always calls build after calling didUpdateComponent, which means any calls to setState in didUpdateComponent are redundant.

Implementations of this method should start with a call to the inherited method, as in super.didUpdateComponent(oldComponent)

Implementation

@override
void didUpdateComponent(Router oldComponent) {
  super.didUpdateComponent(oldComponent);
  if (component == oldComponent) return;
  initRoutes();
}