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]).

  // Likely was deactivated.
  deactivated = false;

  // Add to the list of StateX objects present in the app!
  _addToMapOfStates(this);

  // No 'setState()' functions are allowed to fully function at this point.
  _setStateAllowed = false;

  for (final con in _controllerList) {
    // Supply the State object first
    con._pushStateToSetter(this);

    con.activate();
  }

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

  // Registers the given object as a binding observer.
  WidgetsBinding.instance.addObserver(this);

  _setStateAllowed = true;

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