parse static method
Parses the x,y w×h spelling the capture records.
scale multiplies logical pixels into the image's. Null when the string
is not a rect — a missing box is ordinary (a key can be recorded without
one) and should not take the whole export down.
Implementation
static ExportedRect? parse(String? rect, {double scale = 1}) {
if (rect == null) return null;
var parts = rect.split(' ');
if (parts.length != 2) return null;
var origin = parts.first.split(',');
var size = parts.last.split('×');
if (origin.length != 2 || size.length != 2) return null;
var x = double.tryParse(origin.first);
var y = double.tryParse(origin.last);
var width = double.tryParse(size.first);
var height = double.tryParse(size.last);
if (x == null || y == null || width == null || height == null) return null;
return ExportedRect(
x: (x * scale).round(),
y: (y * scale).round(),
width: (width * scale).round(),
height: (height * scale).round(),
);
}