didUpdateWidget method
Override this method to respond when its StatefulWidget is re-created.
The framework always calls build
after calling didUpdateWidget
, which
means any calls to setState
in didUpdateWidget
are redundant.
Implementation
@protected
@override
@mustCallSuper
void didUpdateWidget(StatefulWidget oldWidget) {
/// No 'setState()' functions are allowed
_setStateAllowed = false;
for (final listener in _beforeList) {
listener.didUpdateWidget(oldWidget);
}
for (final con in _controllerList) {
con.didUpdateWidget(oldWidget);
}
for (final listener in _afterList) {
listener.didUpdateWidget(oldWidget);
}
super.didUpdateWidget(oldWidget);
/// Re-enable setState() function
_setStateAllowed = true;
/// No 'setState()' functions are necessary
_setStateRequested = false;
}