parseDecimal static method
Strict decimal parse: throws IntegerError on overflow, unlike the wrapping constructor.
Implementation
static Uint32 parseDecimal(String s) {
// A valid u32 has at most 10 digits ("4294967295"); rejecting longer
// strings up front means int.parse below never sees more digits than
// that, so it stays exact on web.
if (s.isEmpty || s.length > 10 || !RegExp(r'^[0-9]+$').hasMatch(s)) {
throw ArgumentException.invalidOperationArguments(
"parseDecimal",
reason: 'Invalid decimal literal.',
details: {"value": s},
);
}
final v = int.parse(s);
if (v > _mask32) throw IntegerError.overflow;
return Uint32._(v);
}