performBuild method
void
performBuild()
Implementation
void performBuild() {
assert(!isFirstBuild);
assert(_debugStateLockLevel >= 0);
assert(!_debugBuilding);
assert(() {
_debugStateLockLevel += 1;
_debugBuilding = true;
return true;
}());
try {
_dirtyElements.sort(Element._sort);
_dirtyElementsNeedsResorting = false;
int dirtyCount = _dirtyElements.length;
int index = 0;
while (index < dirtyCount) {
final Element element = _dirtyElements[index];
assert(element._inDirtyList);
try {
element.rebuild();
if (element._lifecycleState == _ElementLifecycle.active) {
assert(!element._dirty, 'Build was not finished synchronously on $element');
}
} catch (e) {
// TODO: properly report error
print("Error on rebuilding component: $e");
rethrow;
}
index += 1;
if (dirtyCount < _dirtyElements.length || _dirtyElementsNeedsResorting!) {
_dirtyElements.sort(Element._sort);
_dirtyElementsNeedsResorting = false;
dirtyCount = _dirtyElements.length;
while (index > 0 && _dirtyElements[index - 1].dirty) {
index -= 1;
}
}
}
assert(() {
if (_dirtyElements
.any((Element element) => element._lifecycleState == _ElementLifecycle.active && element.dirty)) {
throw 'performBuild missed some dirty elements.';
}
return true;
}());
} finally {
for (final Element element in _dirtyElements) {
assert(element._inDirtyList);
element._inDirtyList = false;
}
_dirtyElements.clear();
_dirtyElementsNeedsResorting = null;
lockState(_inactiveElements._unmountAll);
_scheduledBuild = false;
assert(_debugBuilding);
assert(() {
_debugBuilding = false;
_debugStateLockLevel -= 1;
return true;
}());
}
assert(_debugStateLockLevel >= 0);
}