render method

  1. @override
String render({
  1. BoxConstraints? constraints,
})
override

Renders this element subtree to a terminal string.

Implementation

@override
String render({BoxConstraints? constraints}) {
  if (_dirty) {
    _owner?.buildScopeFor(_rootOfTree(this), this);
  }
  final roType = TuiTrace.enabled ? renderObject.runtimeType.toString() : '';
  final span = TuiTrace.begin(
    'ro.render',
    tag: TraceTag.render,
    extra: roType,
  );
  final layoutSw = Stopwatch()..start();
  renderObject.layout(constraints ?? BoxConstraints());
  layoutSw.stop();

  final paintSw = Stopwatch()..start();
  final result = renderObject.paint();
  paintSw.stop();

  // A frame consumed the latest paint output for this subtree.
  // Keep paint-dirty flags edge-triggered so unchanged branches can be
  // skipped by parent render objects on subsequent frames.
  renderObject.clearPaintDirtySubtree();

  // Report phase durations to BuildOwner for frame timing.
  _owner?.recordLayout(layoutSw.elapsed);
  _owner?.recordPaint(paintSw.elapsed);

  span.end(
    extra:
        'layout=${layoutSw.elapsedMicroseconds}us '
        'paint=${paintSw.elapsedMicroseconds}us '
        'size=${renderObject.size.width.toInt()}x${renderObject.size.height.toInt()}',
  );

  return result;
}