fitWidth method

int fitWidth()

Computes the total width needed to fit all children based on direction and childGap.

Implementation

int fitWidth() {
  if (children.isEmpty) return 0;
  int requiredWidth = 0;

  if (direction == Axis.horizontal) {
    requiredWidth += ((children.length - 1) * childGap);
  }

  for (var child in children) {
    if (direction == Axis.horizontal) {
      requiredWidth += child.fitWidth();
    } else {
      requiredWidth = max(child.fitWidth(), requiredWidth);
    }
  }

  return requiredWidth + 20;
}