lockState method
Establishes a scope in which calls to State.setState are forbidden, and
calls the given callback
.
This mechanism is used to ensure that, for instance, State.dispose does not call State.setState.
Implementation
void lockState(void callback()) {
assert(callback != null);
assert(_debugStateLockLevel >= 0);
assert(() {
_debugStateLockLevel += 1;
return true;
}());
try {
callback();
} finally {
assert(() {
_debugStateLockLevel -= 1;
return true;
}());
}
assert(_debugStateLockLevel >= 0);
}