initState method
The framework will call this method exactly once.
Only when the StateX
object is first created.
Implementation
@protected
@override
@mustCallSuper
void initState() {
assert(mounted, '${toString()} is not instantiated properly.');
/// Override this method to perform initialization that depends on the
/// location at which this object was inserted into the tree.
/// (i.e. Subscribe to another object it depends on during [initState],
/// unsubscribe object and subscribe to a new object when it changes in
/// [didUpdateWidget], and then unsubscribe from the object in [dispose].
super.initState();
/// Registers the given object as a binding observer. Binding
/// observers are notified when various application events occur,
/// for example when the system locale changes. Generally, one
/// widget in the widget tree registers itself as a binding
/// observer, and converts the system state into inherited widgets.
WidgetsBinding.instance.addObserver(this);
/// No 'setState()' functions are allowed to fully function at this point.
_setStateAllowed = false;
int cnt = 0;
StateXController con;
// While loop so additional controllers can be added in a previous initState()
final list = _controllerList.length;
while (cnt < list) {
con = _controllerList[cnt];
// Add this to the _StateSets Map
con._addStateToSetter(this);
con.initState();
cnt++;
}
_setStateAllowed = true;
/// No 'setState()' functions are necessary
_setStateRequested = false;
}