parseRectangleFromMap function

Rectangle<num>? parseRectangleFromMap(
  1. Map<String, Object>? map
)

Parses map as a Rectangle.

Implementation

Rectangle<num>? parseRectangleFromMap(Map<String, Object>? map) {
  if (map == null || map.isEmpty) return null;

  var x = parseNum(findKeyValue(map, ['x', 'left'], true));
  var y = parseNum(findKeyValue(map, ['y', 'top'], true));
  var w = parseNum(findKeyValue(map, ['width', 'w'], true));
  var h = parseNum(findKeyValue(map, ['height', 'h'], true));

  if (x == null || y == null || w == null || h == null) return null;

  return Rectangle(x, y, w, h);
}