Uuid.parse constructor
Uuid.parse(
- String input
Parses and returns the provided input
as a UUID.
If not a valid UUID, a FormatException is thrown.
Implementation
factory Uuid.parse(String input) {
if (input.length != 36) {
throw FormatException(
'Expected a 36-length string, got ${input.length}-length',
input,
);
}
final l = _parseHex(input, 0, 8);
_assertHyphen(input, 0 + 8);
final m = _parseHex(input, 9, 4);
_assertHyphen(input, 9 + 4);
final h = _parseHex(input, 14, 4);
_assertHyphen(input, 14 + 4);
final s = _parseHex(input, 19, 4);
_assertHyphen(input, 19 + 4);
final n = _parseHex(input, 24, 12);
// Intentionlaly not validated, as it's impossible *not* to be in range.
return _Uuid(l, m, h, s, n);
}