estimateWidth method

double estimateWidth(
  1. BuildContext context
)

Implementation

double estimateWidth(BuildContext context) {
  // Default horizontal padding is 10*2 = 20
  double width = (padding?.horizontal ?? 20.0);

  if (icon != null) {
    width += 16.0; // Icon size
    if (text != null) width += 4.0; // Spacing
  }

  if (text != null) {
    width += WidthHelper.measureText(context, text!, const TextStyle(fontSize: 12.0, fontWeight: FontWeight.w400));
  }
  return width;
}