import 'dart:io';
//Here's the method to get file size:
double getFileSize(File file){
int sizeInBytes = file.lengthSync();
double sizeInMb = sizeInBytes / (1024 * 1024);
return sizeInMb;
}
//Alternatively for extension:
extension FileUtils on File {
get size {
int sizeInBytes = this.lengthSync();
double sizeInMb = sizeInBytes / (1024 * 1024);
return sizeInMb;
}
}