ConnectionId.fromHexString constructor
ConnectionId.fromHexString(
- String hex
Parse the 32-character big-endian hex form.
Implementation
factory ConnectionId.fromHexString(String hex) {
final normalized = hex.startsWith('0x') ? hex.substring(2) : hex;
if (normalized.length != byteLength * 2) {
throw ArgumentError(
'ConnectionId hex must be ${byteLength * 2} characters, '
'got ${normalized.length}',
);
}
final beBytes = Uint8List(byteLength);
for (var i = 0; i < byteLength; i++) {
beBytes[i] = int.parse(normalized.substring(i * 2, i * 2 + 2), radix: 16);
}
return ConnectionId.fromBigEndianBytes(beBytes);
}