parseZones function
- Object? json
Spots of the picture as fractions of its width and height, from a JSON list of [x1, y1, x2, y2].
Implementation
List<Rect> parseZones(Object? json) => <Rect>[
if (json is List)
for (final zone in json)
if (zone is List &&
zone.length == 4 &&
zone.every((v) => v is num) &&
(zone[0] as num) < (zone[2] as num) &&
(zone[1] as num) < (zone[3] as num))
Rect.fromLTRB(
(zone[0] as num).toDouble(),
(zone[1] as num).toDouble(),
(zone[2] as num).toDouble(),
(zone[3] as num).toDouble(),
),
];