isLiteRtLmFilename function

bool isLiteRtLmFilename(
  1. String filename
)

Whether filename ends in .litertlm, compared ASCII case-insensitively (model.LiteRTLM matches; only A–Z fold, so a non-ASCII look-alike never does).

The one predicate core and engine packages use to tell a .litertlm bundle from any other model file.

Implementation

bool isLiteRtLmFilename(String filename) {
  final start = filename.length - _liteRtLmSuffix.length;
  if (start < 0) return false;
  for (var i = 0; i < _liteRtLmSuffix.length; i++) {
    var c = filename.codeUnitAt(start + i);
    // ASCII 'A'..'Z' → 'a'..'z'; every other code unit compares as is.
    if (c >= 0x41 && c <= 0x5A) c += 0x20;
    if (c != _liteRtLmSuffix.codeUnitAt(i)) return false;
  }
  return true;
}