calculateTotalSize method

TotalSize calculateTotalSize()

Calculate the total size for the defined cell sizes list.

Throws an ArgumentError if any item in the collection is not Weight or Fixed.

Implementation

TotalSize calculateTotalSize() {
  double totalWeightSize = 0;
  double totalFixedSize = 0;
  for (var cellSize in this) {
    switch (cellSize.runtimeType) {
      case Weight:
        totalWeightSize += (cellSize as Weight).size;
        break;
      case Fixed:
        totalFixedSize += (cellSize as Fixed).size;
        break;
      default:
        throw ArgumentError(
          "Unknown type of cell size: ${cellSize.runtimeType}",
        );
    }
  }
  return TotalSize(weight: totalWeightSize, fixed: totalFixedSize);
}