initState method
The framework will call this method exactly once.
Only when the StateMVC
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.
_rebuildAllowed = false;
for (final listener in _beforeList) {
listener.initState();
}
for (final con in _controllerList) {
con.initState();
}
for (final listener in _afterList) {
listener.initState();
}
_rebuildAllowed = true;
}