FileStorageAdapter class
File-based storage adapter providing real persistence on disk across application restarts.
Persists individual keys as JSON files inside baseDirectory (defaulting to system temp directory).
Example:
final fileStorage = FileStorageAdapter(Directory('/var/app/data'));
await fileStorage.write('settings', '{"autoSync": true}');
- Implemented types
Constructors
- FileStorageAdapter([Directory? baseDirectory])
-
Creates a FileStorageAdapter with an optional
baseDirectory.
Properties
- baseDirectory → Directory
-
Base directory path where JSON storage files are persisted.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → Future< void> -
Purges all persisted files and in-memory cache.
override
-
containsKey(
String key) → Future< bool> -
Checks whether a persisted file exists for
key.override -
delete(
String key) → Future< void> -
Deletes file and in-memory cache associated with
key.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
String key) → Future< String?> -
Reads string value associated with
keyfrom disk.override -
toString(
) → String -
A string representation of this object.
inherited
-
write(
String key, String value) → Future< void> -
Writes
valuestring associated withkeyto disk.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited