WebWorkDb class

File system implementation for Web platform using localStorage.

This implementation stores data in the browser's localStorage, making it suitable for web applications.

Limitations

  • localStorage has a size limit (usually 5-10 MB)
  • Data is stored as strings, so all items are JSON serialized
  • Data persists across browser sessions but is domain-specific

Usage

// Using default MapWebStorage (for testing/non-browser)
final fs = WebWorkDb();

// In a browser, you'd use an adapter for window.localStorage
final fs = WebWorkDb(BrowserStorageAdapter(window.localStorage));

final db = ClientWorkDb.getInstance(fs);
Implemented types

Constructors

WebWorkDb([IWebStorage? localStorage])
Creates a new WebWorkDb with the specified storage.

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

deleteFile(String path) → Future<void>
Deletes a file at the specified path.
override
deleteFileSync(String path) → void
Deletes a file at the specified path synchronously.
override
deleteFolder(String folderPath) → Future<void>
Deletes a folder and all its contents recursively.
override
deleteFolderSync(String folderPath) → void
Deletes a folder and all its contents recursively, synchronously.
override
exist(String path) → Future<bool>
Checks if a file or folder exists at the specified path.
override
existSync(String path) → bool
Checks if a file or folder exists at the specified path synchronously.
override
getFile(String path) → Future<ItemOutput>
Reads an item from the specified path.
override
getFileSync(String path) → ItemOutput
Reads an item from the specified path synchronously.
override
getPath() → String
override
ls(String dirPath) → Future<List<String>>
Lists all files/items in a directory.
override
lsSync(String dirPath) → List<String>
Lists all files/items in a directory synchronously.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
renameFile(String oldPath, String newPath) → Future<void>
Renames/moves a file from one path to another.
override
renameFileSync(String oldPath, String newPath) → void
Renames/moves a file from one path to another synchronously.
override
toString() → String
A string representation of this object.
inherited
writeFile(String path, Item input) → Future<void>
Writes an item to the specified path.
override
writeFileSync(String path, Item input) → void
Writes an item to the specified path synchronously.
override

Operators

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