parsePadding static method

EdgeInsets? parsePadding(
  1. dynamic value
)

Implementation

static EdgeInsets? parsePadding(dynamic value) {
  if (value == null) return null;
  if (value is num) return EdgeInsets.all(value.toDouble());
  if (value is List) {
    if (value.length == 2) {
      return EdgeInsets.symmetric(
        vertical: (value[0] as num).toDouble(),
        horizontal: (value[1] as num).toDouble(),
      );
    }
    if (value.length == 4) {
      return EdgeInsets.fromLTRB(
        (value[3] as num).toDouble(),
        (value[0] as num).toDouble(),
        (value[1] as num).toDouble(),
        (value[2] as num).toDouble(),
      );
    }
  }
  return null;
}