u8aFixLength function
Implementation
Uint8List u8aFixLength(
Uint8List value, {
int bitLength = -1,
bool atStart = false,
}) {
final byteLength = (bitLength / 8).ceil();
if (bitLength == -1 || value.length == byteLength) {
return value;
} else if (value.length > byteLength) {
return value.sublist(0, byteLength);
}
final result = Uint8List(byteLength);
if (atStart) {
result.setRange(0, value.length, value);
} else {
result.setRange(byteLength - value.length, byteLength, value);
}
return result;
}