trimEnd static method

List<int> trimEnd(
  1. List<int> bytes
)

Remove a series of 0x00 in the footer

Implementation

static List<int> trimEnd(List<int> bytes) {
  if (bytes.isEmpty) return [];
  int i = bytes.length - 1;
  while (bytes[i] == 0x00) {
    i--;
    if (i < 0) {
      return [];
    }
  }
  return bytes.sublist(0, i + 1);
}