resolveMinWidth static method

double resolveMinWidth(
  1. String columnName, {
  2. TextStyle? headerStyle,
  3. double paddingHorizontal = 24.0,
  4. double sortIconWidth = 20.0,
  5. double minFloor = 100.0,
  6. double maxCap = 320.0,
})

Computes the minimum column width needed to display columnName without truncation, including padding and sort-icon allowance.

Implementation

static double resolveMinWidth(
    String columnName, {
      TextStyle? headerStyle,
      double paddingHorizontal = 24.0,
      double sortIconWidth = 20.0,
      double minFloor = 100.0,
      double maxCap = 320.0,
    }) {
  final style = headerStyle ??
      const TextStyle(fontWeight: FontWeight.bold, fontSize: 14);

  final painter = TextPainter(
    text: TextSpan(text: columnName, style: style),
    textDirection: TextDirection.ltr,
  )..layout();

  final computed = painter.width + paddingHorizontal + sortIconWidth;
  return computed.clamp(minFloor, maxCap);
}