validateMaxSize method

String? validateMaxSize(
  1. int maxSizeInBytes
)

Validates file size against a max limit in bytes.

Implementation

String? validateMaxSize(int maxSizeInBytes) {
  if (!existsSync()) {
    return "File does not exist.";
  }
  if (lengthSync() > maxSizeInBytes) {
    return "File exceeds maximum allowed size of \$maxSizeInBytes bytes.";
  }
  return null;
}