border method

IrStroke? border(
  1. DartValue? v
)

Border.all(...) or a uniform Border(...).

Implementation

IrStroke? border(DartValue? v) {
  final d = deref(v);
  if (d is! ObjectValue || d.type != 'Border') return null;
  if (d.constructor == 'all') {
    return IrStroke(
      color: color(d['color']) ?? IrColor.black,
      width: number(d['width']) ?? 1,
    );
  }
  if (d.constructor == 'fromBorderSide') return borderSide(d.arg(0));
  // Non-uniform borders: use the first side that is set.
  for (final side in ['top', 'right', 'bottom', 'left']) {
    final s = borderSide(d[side]);
    if (s != null) return s;
  }
  return null;
}