rect static method

Rect? rect(
  1. DataSource source,
  2. List<Object> key
)

Returns a Rect from the specified map.

If the map is absent, returns null.

Otherwise, returns a Rect.fromLTWH whose x, y, width, and height components are determined from the x, y, w, and h properties of the map, with missing (or non-double) values replaced by zeros.

Implementation

static Rect? rect(DataSource source, List<Object> key) {
  if (!source.isMap(key)) {
    return null;
  }
  final double x = source.v<double>([...key, 'x']) ?? 0.0;
  final double y = source.v<double>([...key, 'y']) ?? 0.0;
  final double w = source.v<double>([...key, 'w']) ?? 0.0;
  final double h = source.v<double>([...key, 'h']) ?? 0.0;
  return Rect.fromLTWH(x, y, w, h);
}