getInsets method

EdgeInsets? getInsets(
  1. dynamic value
)

Implementation

EdgeInsets? getInsets(dynamic value) {
  if (value == null) return null;
  if (value is num) return EdgeInsets.all(parseDouble(value));

  var parts = value.toString().split(RegExp(r'[|\s]'));
  if (parts.length > 2) {
    return EdgeInsets.fromLTRB(parseDouble(parts[0]), parseDouble(parts[1]),
        parseDouble(parts[2]), parseDouble(parts[3]));
  } else if (parts.length > 1) {
    return EdgeInsets.symmetric(
        vertical: parseDouble(parts[0]), horizontal: parseDouble(parts[1]));
  } else {
    return EdgeInsets.all(parseDouble(parts[0]));
  }
}