calculateDayWidth method

double calculateDayWidth(
  1. double totalWidth
)

Calculates the width of a single day column based on the total available width. Also updates internal layout cache (_gridEndX, _gridWidth). Returns 0 if calculation is not possible.

Implementation

double calculateDayWidth(double totalWidth) {
  _gridEndX = totalWidth - sidePadding;
  _gridWidth = _gridEndX - gridStartX; // gridStartX is sidePadding (10.0)
  // Ensure daysToShow is positive to prevent division by zero or negative width
  final double calculatedWidth =
      _gridWidth > 0 && daysToShow > 0 ? _gridWidth / daysToShow : 0;

  _dayWidth =
      calculatedWidth; // Store the calculated width for drawing methods
  return calculatedWidth;
}