Uuid.fromBytes constructor
Uuid.fromBytes(
- ByteBuffer uuidBytes
Construct a UUID from the given byte buffer.
The given uuidBytes
will be copied to prevent modifications.
This method throws an ArgumentError if, and only if, the uuidBytes
buffer wasn't exactly 16 bytes (see kUuidBytes) long.
Implementation
factory Uuid.fromBytes(ByteBuffer uuidBytes) {
if (uuidBytes.lengthInBytes != kUuidBytes) {
throw ArgumentError.value(
uuidBytes,
'uuidBytes',
'Must be $kUuidBytes bytes long, was ${uuidBytes.lengthInBytes}',
);
}
final copy = Uint8List(uuidBytes.lengthInBytes);
final inputList = uuidBytes.asInt8List();
for (var index = 0; index < copy.length; index += 1) {
copy[index] = inputList[index];
}
return Uuid._fromValidBytes(copy.buffer);
}