Skip to main content
Methods like fileFormattedSize() and fileToBase64String() use synchronous I/O (lengthSync, readAsBytesSync) and should be run off the main thread (e.g., in an Isolate or compute) for large files to prevent UI jank.

1

🔗 Path & Naming

filePath()
String
Retrieves the absolute path of the file.
final path = file.filePath();

//  Output: /data/user/0/app.name/cache/temp.txt
fileExtension()
String
Retrieves the file extension (the part after the last dot), e.g., “png”, “pdf”.
print(File('/img/photo.png').fileExtension()); // png
fileNameWithoutExtension()
String
Retrieves the file name without the extension. “pdf”.
print(File('/docs/report.pdf').fileNameWithoutExtension()); // report
2

🖼️ Content & Type Checks

fileToBase64String()
String
Reads the file contents synchronously and converts them to a Base64 encoded string.
final base64 = file.fileToBase64String();