transferToLength method
Convert bytes to bytes of specified length
- bytes
- byteLength
Optional
Implementation
List<int> transferToLength(List<int> bytes, {int? byteLength}) {
if (byteLength == null) return bytes;
final List<int> ret = List.from(bytes);
if (bytes.length <= byteLength) {
ret.addAll(List.filled(byteLength - bytes.length, 0x00));
return ret;
} else {
ret.removeRange(byteLength, bytes.length);
return ret;
}
}