calculateBarWidth method

double calculateBarWidth()
  • FUNCTION TO DYNAMICALLY CALCULATE TOTAL WIDTH OF THE NAVBAR

Implementation

double calculateBarWidth() {
  double totalWidth = itemWidth * items.length; // TOTAL WIDTH WITH ALL ITEMS
  double paddingWidth =
      8.0 * (items.length - 1); // TOTAL WIDTH OF SPACING BETWEEN ITEMS
  double totalBarWidth = totalWidth + paddingWidth; // TOTAL BAR WIDTH

  return totalBarWidth;
}