looksLikeAsciiStl function

bool looksLikeAsciiStl(
  1. Uint8List bytes
)

True when bytes looks like the text dialect: solid (any case), once leading whitespace is skipped.

Checked only after isBinaryStl says no — see that function's doc comment for why the order matters.

Implementation

bool looksLikeAsciiStl(Uint8List bytes) {
  var i = 0;
  while (i < bytes.length) {
    final byte = bytes[i];
    if (byte != 0x20 && byte != 0x09 && byte != 0x0A && byte != 0x0D) break;
    i++;
  }
  if (i + 5 > bytes.length) return false;
  return String.fromCharCodes(bytes, i, i + 5).toLowerCase() == 'solid';
}