effectiveCellWidth property

List<double> get effectiveCellWidth

根据当前 rowWidth 与列权重计算的“最终展示宽度”(优先按权重占比)。

规则:

  • 若存在 cellFlex 且总和 > 0:按占比分配 (width_i = rowWidth * flex_i / sumFlex)
  • 否则退化为 cellWidth
  • rowWidth 大于 cellWidth 之和时,会将 cellWidth 等比放大填充整行

Implementation

List<double> get effectiveCellWidth {
  final base = cellWidth ?? const <double>[];
  final w = rowWidth;
  if (w == null || w <= 0) return List<double>.from(base);

  final flex = cellFlex;
  if (flex != null && flex.isNotEmpty) {
    final sumFlex = flex.fold<double>(0, (p, e) => p + e);
    if (sumFlex > 0) {
      return flex.map((f) => w * (f / sumFlex)).toList();
    }
  }

  final sumBase = base.fold<double>(0, (p, e) => p + e);
  if (sumBase > 0 && w > sumBase) {
    final scale = w / sumBase;
    return base.map((e) => e * scale).toList();
  }

  return List<double>.from(base);
}