deactivate method
The framework calls this method whenever it removes this State object from the tree.
Implementation
@protected
@override
@mustCallSuper
void deactivate() {
/// The framework calls this method whenever it removes this [State] object
/// from the tree. Subclasses should override this method to clean up any links between
/// this object and other elements in the tree.
// Indicate this State object is deactivated.
deactivated = true;
// Unregisters the given observer.
WidgetsBinding.instance.removeObserver(this);
// No 'setState()' functions are allowed to fully function at this point.
_setStateAllowed = false;
for (final listener in _beforeList) {
listener.deactivate();
}
for (final con in _controllerList) {
//
con.deactivate();
// Pop the State object from the controller
con._popStateFromSetter(this);
}
for (final listener in _afterList) {
listener.deactivate();
}
super.deactivate();
// Remove from the list of StateX objects present in the app!
_removeFromMapOfStates(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;
}