layout method

Size layout(
  1. BoxConstraints constraints
)

Calculates the size of the element based on the given constraints.

Implementation

Size layout(BoxConstraints constraints) {
  final isTracing =
      Tracer.isEnabled &&
      Tracer.activeCategories.contains(TraceCategory.build);
  if (isTracing) {
    Tracer.record(
      layoutTraceId,
      Phase.begin,
      TraceCategory.build,
      metadata: null,
    );
  }
  try {
    _cachedConstraints = constraints;
    final resolvedSize = performLayout(constraints);
    _cachedSize = constraints.constrain(resolvedSize);
    return _cachedSize!;
  } finally {
    if (isTracing) {
      Tracer.record(layoutTraceId, Phase.end, TraceCategory.build);
    }
  }
}