activate method

  1. @override
  2. @mustCallSuper
void activate()
inherited

Called when this object is reinserted into the tree after having been removed via deactivate.

Implementation

@override
@mustCallSuper
void activate() {
  /// In most cases, after a [State] object has been deactivated, it is _not_
  /// reinserted into the tree, and its [dispose] method will be called to
  /// signal that it is ready to be garbage collected.
  ///
  /// In some cases, however, after a [State] object has been deactivated, the
  /// framework will reinsert it into another part of the tree (e.g., if the
  /// subtree containing this [State] object is grafted from one location in
  /// the tree to another due to the use of a [GlobalKey]).

  _deactivated = false;

  /// No 'setState()' functions are allowed to fully function at this point.
  _rebuildAllowed = false;
  for (final listener in _beforeList) {
    listener.activate();
  }
  for (final con in _controllerList) {
    // Don't call its activate if it's in other State objects.
    if (con._stateMVCSet.isEmpty) {
      con.activate();
    }
  }
  for (final listener in _afterList) {
    listener.activate();
  }

  /// Must call the 'super' routine as well.
  super.activate();
  _rebuildAllowed = true;

  /// In some cases, if then reinserted back in another part of the tree
  /// the build is called, and so setState() is not necessary.
  _rebuildRequested = false;
}