checkFileNameAndFormat method

void checkFileNameAndFormat(
  1. String name,
  2. CompressFormat format
)

Implementation

void checkFileNameAndFormat(String name, CompressFormat format) {
  if (ignoreCheckExtName) {
    return;
  }
  name = name.toLowerCase();
  if (format == CompressFormat.jpeg) {
    assert(
      (name.endsWith('.jpg') || name.endsWith('.jpeg')),
      'The jpeg format name must end with jpg or jpeg.',
    );
  } else if (format == CompressFormat.png) {
    assert(
      name.endsWith('.png'),
      'The png format name must end with png.',
    );
  } else if (format == CompressFormat.heic) {
    assert(
      name.endsWith('.heic'),
      'The heic format name must end with heic.',
    );
  } else if (format == CompressFormat.webp) {
    assert(
      name.endsWith('.webp'),
      'The webp format name must end with webp.',
    );
  }
}