calculateTotalRequiredWidth<T, K> static method
double
calculateTotalRequiredWidth<T, K>(
- List<
TTableHeader< headers,T, K> > - bool selectable,
- bool expandable, {
- int maxTreeLevel = 0,
Calculates the minimum total width required for the table view.
Implementation
static double calculateTotalRequiredWidth<T, K>(
List<TTableHeader<T, K>> headers,
bool selectable,
bool expandable, {
int maxTreeLevel = 0,
}) {
double totalWidth = 0;
// Add width for expand/select columns
if (expandable) totalWidth += 50;
if (selectable) totalWidth += 50;
final treeIndentBonus = maxTreeLevel > 0 ? (maxTreeLevel * 16.0 + 48.0) : 0.0;
for (int i = 0; i < headers.length; i++) {
final header = headers[i];
final extraWidth = (i == 0) ? treeIndentBonus : 0.0;
if (header.maxWidth != null && header.maxWidth != double.infinity) {
totalWidth += header.maxWidth! + extraWidth;
} else if (header.minWidth != null && header.minWidth! > 0) {
totalWidth += header.minWidth! + extraWidth;
} else {
// For flex columns, assume a minimum reasonable width
totalWidth += 100 + extraWidth; // Default minimum width for flex columns
}
}
// Add some padding for table margins/padding
totalWidth += 32; // Account for horizontal padding
return totalWidth;
}