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
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
fileNamefrom the specifiedfolderPath. -
readFile(
String folderPath, String fileName) → Future< Uint8List?> -
Reads the contents of a binary file with the given
fileNamefrom the specifiedfolderPath. -
readTextFile(
String folderPath, String fileName) → Future< String?> -
Reads the contents of a text file with the given
fileName(without extension) from the specifiedfolderPath. The file is expected to have a.txtextension. -
saveFile(
String folderPath, String fileName, Uint8List contents) → Future< void> -
Saves a binary file with the given
fileNameandcontents(as Uint8List) to the specifiedfolderPath. -
saveTextFile(
String folderPath, String fileName, String contents) → Future< void> -
Saves a text file with the given
fileName(without extension) andcontentsto the specifiedfolderPath. The file will have a.txtextension.