Returns the file size depending on whether it's Uint8List or File.
int getFileSize(dynamic file) { if (file is Uint8List) { return file.length; } if (file is File) { return file.lengthSync(); } throw FileTypeError(); }