Skip to main content
1

Formatting

fileFormattedSize()
String
Retrieves the file size and formats it into human-readable units (B, KB, MB, GB).
final size = file.fileFormattedSize(fullySizedName: true);
print(size); // 5.32 Megabytes
2

Getters

sizeInBytes
double
Returns the file size in raw Bytes as a double.
final size = file.sizeInBytes; // 1048576.0 for a 1MB file
sizeInKB
double
Returns the file size in Kilobytes (KB) as a [double].
print(file.sizeInKB); // 1024.0 for a 1MB file
sizeInMB
double
Returns the file size in Megabytes (MB) as a [double].
print(file.sizeInMB); // 1.0 for a 1MB file
sizeInGB
double
Returns the file size in Gigabytes (GB) as a [double].
print(file.sizeInGB); // 0.0009765625 for a 1MB file
3

Comparators

isLargerThanMb()
bool
Checks if the file size is strictly greater than the specified size in Megabytes (MB).
print(file.isLargerThanMb(50)); // true if file is 50.01MB
isSmallerThanMb()
bool
Checks if the file size is strictly less than the specified size in Megabytes (MB).
print(file.isSmallerThanMb(0.5)); // true if file is 400KB
isLargerThanFile()
bool
Checks if this file is larger than another File object by comparing raw byte counts.
print(fileA.isLargerThanFile(fileB));
isSmallerThanFile()
bool
Checks if this file is smaller than another File object by comparing raw byte counts.
print(fileA.isSmallerThanFile(fileB));
isSameSizeAsFile()
bool
Checks if this file has the exact same size (byte count) as another [File] object.
print(fileA.isSameSizeAsFile(fileB));
isSizeBetween()
bool
Checks if the file size falls inclusively between the specified minimum and maximum sizes in Megabytes (MB).
// Check if file is between 500 KB (0.5 MB) and 10 MB
print(file.isSizeBetween(minMB: 0.5, maxMB: 10));
4

Manipulators

percentageOfLimitMb()
double
Calculates the file’s size as a percentage of a given total size limit.
// If file is 5MB and limit is 100MB, returns 5.0
print(file.percentageOfLimitMb(100));