I need to avoid files bigger than 10MB.

I can check the file size doing something like this:

final file = File('whateveripicked.mp4');
print(file.lengthSync()); 

And do some checks after but that doesn't provide the best UX.

I'd like to exclude big files and hide them on the gallery. Is this kind of filter possible?


Solution 1: Nilesh Senta

final f = File('whateveripicked.mp4');
int sizeInBytes = f.lengthSync(); double sizeInMb = sizeInBytes / (1024 * 1024); if (sizeInMb > 10){ // This file is Longer the }


Solution 2: Tomáš Komenda

int filePickerSize = file.size!;
String filePickerPath = file.path!;
String filePickerExtension = file.extension!;