didUpdateWidget method

  1. @protected
  2. @override
  3. @mustCallSuper
void didUpdateWidget(
  1. covariant StatefulWidget oldWidget
)
override

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

Implementation

@protected
@override
@mustCallSuper
void didUpdateWidget(StatefulWidget oldWidget) {
  /// The framework always calls [build] after calling [didUpdateWidget], which
  /// means any calls to [setState] in [didUpdateWidget] are redundant.

  /// No 'setState()' functions are allowed
  /// The framework always calls build after calling didUpdateWidget,
  /// which means any calls to setState in didUpdateWidget are redundant.
  _rebuildAllowed = false;
  for (final listener in _beforeList) {
    listener.didUpdateWidget(oldWidget);
  }
  for (final con in _controllerList) {
    con.didUpdateWidget(oldWidget);
  }
  for (final listener in _afterList) {
    listener.didUpdateWidget(oldWidget);
  }
  super.didUpdateWidget(oldWidget);
  _rebuildAllowed = true;

  /// No 'setState()' functions are necessary
  _rebuildRequested = false;
}