for getting file size in bytes size = await image.readAsBytes()
or size = image.readAsBytesSync()
then you can put this method in your utils class or something like that to get the Size Unit Dynamically
you can use this method, this is worked.
void getFileFromGallery()async{
FilePickerResult? result = await FilePicker.platform.pickFiles(
type: FileType.custom,
allowedExtensions: ['jpg', 'pdf', 'mp4'],
);
if (result != null) {
File file = File(result.files.single.path!);
var size = file.lengthSync();
print("file siz is : ${file.lengthSync()}");
if(size > 1000000){
Fluttertoast.showToast(msg: "your file too big, you can ""upload under 2mb file");
}else{
// pick file
}
} else {
// User canceled the picker
}
}