resolve method

Map<int, TableColumnWidth> resolve(
  1. double availableWidth
)

Implementation

Map<int, TableColumnWidth> resolve(double availableWidth) {
  final result = Map<int, TableColumnWidth>.from(fixedWidths);
  if (autoIndices.isEmpty) return result;

  final total = autoNaturalTotal;
  final availableForAuto = availableWidth.isFinite ? (availableWidth - TTableTheme.horizontalChrome - fixedTotal) : double.infinity;
  final scale = (total > 0 && availableForAuto.isFinite) ? math.max(1.0, availableForAuto / total) : 1.0;

  for (int j = 0; j < autoIndices.length; j++) {
    var width = autoNaturalWidths[j] * scale;
    // Re-clamp AFTER scaling: scale can push a max-capped basis back
    // over the ceiling (e.g. basis=100, scale=1.7 → 170), and this is
    // the only place that's caught. Min is defensive — scale is
    // currently always >= 1.0, so basis already satisfies min on its
    // own, but this keeps the guarantee explicit if that ever changes.
    final max = autoMaxWidths[j];
    final min = autoMinWidths[j];
    if (max != null && width > max) width = max;
    if (min != null && width < min) width = min;
    result[autoIndices[j]] = FixedColumnWidth(width);
  }
  return result;
}