openOpfsBytesFile function

Future<BytesFile> openOpfsBytesFile(
  1. String path, {
  2. bool create = true,
  3. bool readOnly = false,
  4. int chunkSize = kDefaultChunkSize,
  5. int? workers,
})

Opens (or creates) a logical file backed by OPFS chunks.

  • create: create an empty file when it does not exist (ignored when readOnly is true, matching dart:io's FileMode.read).
  • readOnly: rejects every mutating call with a StateError.
  • chunkSize: only used when the file is created; existing files keep the chunk size recorded in their manifest. Defaults to 16 MiB.
  • workers: chunk workers in the page-wide pool; the first open wins. Defaults to OpfsWorkerPool.defaultWorkers.

Throws UnsupportedError when the browser has no OPFS / worker sync handle, WebFileSystemException with NotFoundError when create is false and the file is missing, and WebQuotaExceededException when the origin is full.

Implementation

Future<BytesFile> openOpfsBytesFile(
  String path, {
  bool create = true,
  bool readOnly = false,
  int chunkSize = kDefaultChunkSize,
  int? workers,
}) {
  return WebOpfsBytesFile.open(
    path,
    create: create,
    readOnly: readOnly,
    chunkSize: chunkSize,
    workers: workers,
  );
}