resolveWidth static method

double? resolveWidth(
  1. BuildContext ctx,
  2. Object? action
)

Implementation

static double? resolveWidth(BuildContext ctx, Object? action) {
  if (action == null) return null;
  return switch (action) {
    SizedBox s => s.width,
    ConstrainedBox cb => cb.constraints.resolvedWidth,
    Container c => c.constraints?.resolvedWidth ?? (c.child != null ? resolveWidth(ctx, c.child!) : null),
    BoxConstraints c => c.resolvedWidth,
    Padding p => (p.child != null ? (resolveWidth(ctx, p.child!) ?? 0) : 0.0) + p.padding.horizontal,
    Flexible f => resolveWidth(ctx, f.child),
    Row r => r.children.fold<double>(0.0, (double sum, child) => sum + (resolveWidth(ctx, child) ?? 0.0)),
    TButton b => b.estimateWidth(ctx),
    TCheckbox cb => cb.estimateWidth(ctx),
    TSwitch s => s.estimateWidth(ctx),
    TChip c => c.estimateWidth(ctx),
    TImage i => i.estimateWidth(ctx),
    TTabs t => t.estimateWidth(ctx),
    TTextField tf => tf.estimateWidth(ctx),
    TButtonGroup bg => bg.estimateWidth(ctx),
    TDropdown d => resolveWidth(ctx, d.child),
    _ => null,
  };
}