tryParse static method

SvgViewBox? tryParse(
  1. String raw
)

Parses minX minY width height.

Implementation

static SvgViewBox? tryParse(String raw) {
  final List<String> parts = raw
      .trim()
      .split(RegExp(r'[\s,]+'))
      .where((String s) => s.isNotEmpty)
      .toList();
  if (parts.length < 4) {
    return null;
  }
  final double? a = double.tryParse(parts[0]);
  final double? b = double.tryParse(parts[1]);
  final double? c = double.tryParse(parts[2]);
  final double? d = double.tryParse(parts[3]);
  if (a == null || b == null || c == null || d == null || c <= 0 || d <= 0) {
    return null;
  }
  return SvgViewBox(a, b, c, d);
}