estimateWidth method

double estimateWidth(
  1. BuildContext context
)

Implementation

double estimateWidth(BuildContext context) {
  if (items.isEmpty) return 0;
  if (cycle) {
    double maxItemWidth = 0;
    for (final item in items) {
      final btn = TButton(icon: item.icon, text: item.text, size: size);
      final w = btn.estimateWidth(context);
      if (w > maxItemWidth) maxItemWidth = w;
    }
    return maxItemWidth;
  }

  double totalWidth = 0;
  for (var i = 0; i < items.length; i++) {
    final item = items[i];
    final btn = TButton(icon: item.icon, text: item.text, size: size);
    totalWidth += btn.estimateWidth(context);
  }
  return totalWidth;
}