CacheStorage class

A utility class for performing basic file operations such as saving, reading, and deleting files in a specified folder. Supports both text and binary files.

All methods are static and asynchronous.

Example usage:

await CacheStorage.saveTextFile('/path/to/folder', 'example', 'Hello, World!');
String? contents = await CacheStorage.readTextFile('/path/to/folder', 'example');
await CacheStorage.delete('/path/to/folder', 'example.txt');

Constructors

CacheStorage()

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

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

delete(String folderPath, String fileName) Future<void>
Deletes the file with the given fileName from the specified folderPath.
readFile(String folderPath, String fileName) Future<Uint8List?>
Reads the contents of a binary file with the given fileName from the specified folderPath.
readTextFile(String folderPath, String fileName) Future<String?>
Reads the contents of a text file with the given fileName (without extension) from the specified folderPath. The file is expected to have a .txt extension.
saveFile(String folderPath, String fileName, Uint8List contents) Future<void>
Saves a binary file with the given fileName and contents (as Uint8List) to the specified folderPath.
saveTextFile(String folderPath, String fileName, String contents) Future<void>
Saves a text file with the given fileName (without extension) and contents to the specified folderPath. The file will have a .txt extension.