flushPaint method

void flushPaint ()

Update the display lists for all render objects.

This function is one of the core stages of the rendering pipeline. Painting occurs after layout and before the scene is recomposited so that scene is composited with up-to-date display lists for every render object.

See RendererBinding for an example of how this function is used.

Implementation

void flushPaint() {
  if (!kReleaseMode) {
    Timeline.startSync('Paint', arguments: timelineWhitelistArguments);
  }
  assert(() {
    _debugDoingPaint = true;
    return true;
  }());
  try {
    final List<RenderObject> dirtyNodes = _nodesNeedingPaint;
    _nodesNeedingPaint = <RenderObject>[];
    // Sort the dirty nodes in reverse order (deepest first).
    for (RenderObject node in dirtyNodes..sort((RenderObject a, RenderObject b) => b.depth - a.depth)) {
      assert(node._layer != null);
      if (node._needsPaint && node.owner == this) {
        if (node._layer.attached) {
          PaintingContext.repaintCompositedChild(node);
        } else {
          node._skippedPaintingOnLayer();
        }
      }
    }
    assert(_nodesNeedingPaint.isEmpty);
  } finally {
    assert(() {
      _debugDoingPaint = false;
      return true;
    }());
    if (!kReleaseMode) {
      Timeline.finishSync();
    }
  }
}