maybeParse static method

SizingValue? maybeParse(
  1. dynamic value
)

Implementation

static SizingValue? maybeParse(dynamic value) {
  if (value == null) return null;

  if (value is Map<String, dynamic>) {
    final sizing = DimensionValue.maybeParse(value['sizing']);
    final width = DimensionValue.maybeParse(value['width']);
    final height = DimensionValue.maybeParse(value['height']);

    if (sizing == null && width == null && height == null) return null;

    if (sizing != null) {
      return SizingValue._(width: sizing, height: sizing);
    } else {
      return SizingValue._(width: width, height: height);
    }
  } else {
    final sizing = DimensionValue.maybeParse(value);
    if (sizing != null) {
      return SizingValue._(width: sizing, height: sizing);
    }
  }
  return null;
}