isJpg method

bool isJpg ()

check if is jpg file

Implementation

bool isJpg() {
  final soiMarker = codeUnits.sublist(0, 2);
  final jfifMarker = codeUnits.sublist(2, 4);

  if (!MoreList.compare(soiMarker, <int>[255, 216])) return false; // ffd8

  final jfif = MoreList.foldHex(jfifMarker);
  if (!validJFIFMarkers.containsKey(jfif)) return false;

  final expected = validJFIFMarkers[jfif];
  final got = MoreList.foldHex(codeUnits.sublist(6, 11));
  return (got == expected) || (jfif == 'ffdb');
}