FileIOWeb class

Web platform implementation using File System Access API Works on: Chrome 86+, Edge 86+, Opera 72+ (modern browsers only)

Note: This implementation requires user interaction to pick files. For web, "filePath" is interpreted as:

  • "picker" or null: Prompt user to pick a file
  • Valid File object reference: Use that file directly
Implemented types

Constructors

FileIOWeb()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearCache() → void
Clear the file cache
computeFileHash(String filePath) → Stream<FileHashProgress>
Computes SHA256 hash of a file by reading it in chunks Returns stream updates with progress and a final event containing FileHashProgress.hash
override
downloadToUser(String filename, Uint8List data) → Future<void>
Download a file to the user's downloads folder using browser download This is the web equivalent of saving to a file path
fileExists(String filePath) → Future<bool>
Checks if a file exists at the given path
override
getFileSize(String filePath) → Future<int>
Gets the size of a file in bytes
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readFile(String filePath) → Future<Uint8List>
Reads entire file into memory as Uint8List
override
readFileAsStream(String filePath, {int chunkSize = 8192}) → Stream<Uint8List>
Reads a file in chunks and returns a stream of bytes chunkSize determines the size of each chunk (default 8KB)
override
registerFile(String key, File file) → void
Register an existing File object with a key Useful when you already have a file from a file picker
toString() → String
A string representation of this object.
inherited
writeFile(String filePath, Uint8List data) → Future<void>
Writes bytes to a file at the given path Creates the file if it doesn't exist, overwrites if it does
override
writeFileStream(String filePath, Stream<Uint8List> dataStream) → Future<void>
Writes a stream of bytes to a file at the given path Creates the file if it doesn't exist, overwrites if it does
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited