insets method

IrInsets? insets(
  1. DartValue? v
)

Implementation

IrInsets? insets(DartValue? v) {
  final d = deref(unwrapStateProperty(v));
  if (d is! ObjectValue) return null;
  if (d.type != 'EdgeInsets' && d.type != 'EdgeInsetsDirectional') {
    return null;
  }
  double n(DartValue? x) => number(x) ?? 0;
  switch (d.constructor) {
    case 'all':
      return IrInsets.all(n(d.arg(0)));
    case 'symmetric':
      return IrInsets.symmetric(
        horizontal: n(d['horizontal']),
        vertical: n(d['vertical']),
      );
    case 'only':
      return IrInsets(
        top: n(d['top']),
        bottom: n(d['bottom']),
        left: n(d['left'] ?? d['start']),
        right: n(d['right'] ?? d['end']),
      );
    case 'fromLTRB' || 'fromSTEB':
      return IrInsets(
        left: n(d.arg(0)),
        top: n(d.arg(1)),
        right: n(d.arg(2)),
        bottom: n(d.arg(3)),
      );
    case 'zero':
      return IrInsets.zero;
  }
  return null;
}