importProgramFromFile method Null safety

void importProgramFromFile(
  1. Uint8List original
)

Implementation

void importProgramFromFile(Uint8List original) {
  if (original.length > 1 && original[0] == 0xff && original[1] == 0xfe) {
    // UTF-16 LE (little endian).  It's not even supported by Dart's
    // encoder!  Also, Dart doesn't seem to have a little-endian to
    // native-endian converter.
    final sb = StringBuffer();
    for (int i = 2; i < original.length - 1; i += 2) {
      final code = original[i] | (original[i + 1] << 8);
      sb.writeCharCode(code);
    }
    return importProgram(sb.toString());
  } else {
    // Default to UTF8
    return importProgram(utf8.decoder.convert(original));
  }
}