flushSemantics method
Update the semantics for render objects marked as needing a semantics update.
Initially, only the root node, as scheduled by RenderObject.scheduleInitialSemantics, needs a semantics update.
This function is one of the core stages of the rendering pipeline. The semantics are compiled after painting and only after RenderObject.scheduleInitialSemantics has been called.
See RendererBinding for an example of how this function is used.
Implementation
void flushSemantics() {
if (_semanticsOwner == null)
return;
profile(() { Timeline.startSync('Semantics'); });
assert(_semanticsOwner != null);
assert(() { _debugDoingSemantics = true; return true; }());
try {
final List<RenderObject> nodesToProcess = _nodesNeedingSemantics.toList()
..sort((RenderObject a, RenderObject b) => a.depth - b.depth);
_nodesNeedingSemantics.clear();
for (RenderObject node in nodesToProcess) {
if (node._needsSemanticsUpdate && node.owner == this)
node._updateSemantics();
}
_semanticsOwner.sendSemanticsUpdate();
} finally {
assert(_nodesNeedingSemantics.isEmpty);
assert(() { _debugDoingSemantics = false; return true; }());
profile(() { Timeline.finishSync(); });
}
}