decode static method Null safety

Uint8List decode(
  1. String input
)

Implementation

static Uint8List decode(String input) {
  int bn = 8; // bit needed
  int bv = 0; // bit value
  int maxLen = (input.length * 15 + 7) ~/ 8;
  Uint8List out = new Uint8List(maxLen);
  int pos = 0;
  int cv;
  for (int code in input.codeUnits) {
    if (code > 0x33FF && code < 0xD7A4) {
      if (code > 0xABFF) {
        cv = code - 0x57A4;
      } else if (code > 0x8925) {
        continue; // invalid range
      } else if (code > 0x4DFF) {
        cv = code - 0x34CA;
      } else if (code > 0x4DB5) {
        continue; // invalid range
      } else if (code > 0x347F) {
        cv = code - 0x3480;
      } else {
        cv = code - 0x3400;
        out[pos++] = (bv << bn) | (cv >> (7 - bn));
        break; // last 8 bit data received, break
      }
      out[pos++] = (bv << bn) | (cv >> (15 - bn));
      bv = cv;
      bn -= 7;
      if (bn < 1) {
        out[pos++] = bv >> -bn;
        bn += 8;
      }
    }
  }
  return out.sublist(0, pos);
}