DiscData class

High-level API for reading/writing files on disk, abstracting away the per-platform differences (path separators, default root directory, hidden-directory conventions, ...).

Access the singleton through DiscData.instance.

Properties

databasesPath Future<String>
Directory where SQLite database files are stored.
no setter
filesPath Future<String>
Directory used to store user-facing files saved by the package.
no setter
hashCode int
The hash code for this object.
no setterinherited
pathJoin String
Platform path separator ('\' on Windows, '/' elsewhere).
final
rootPath Future<String>
Root directory for the current application. Equivalent to getApplicationDocumentsDirectory().path.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

appendDataToFile(Object? data, DataType dataType, {String? fileName, String? path}) Future<void>
Appends data to an existing file on disk.
checkFileExists({String? fileName, String? path}) Future<bool>
Returns true if the file identified by fileName (relative to filesPath) or by the absolute path exists on disk.
deleteFile({String? fileName, String? path}) Future<bool>
Deletes a file on disk.
getEntityFileOnDisc<D, T>(String urlColumnName, String key, Object value, {String? path}) Future<D?>
Loads a file whose name is stored in a column of an SQLite table.
getFile({String? fileName, String? path}) Future<File?>
Returns the file handle, or null when the file does not exist.
getImageFromDisc({String? imageName, String? path, BoxFit fit = BoxFit.fill}) Future<Image?>
Loads an image from disk and returns an Image widget.
getParentDir(String path) String
Returns the parent directory of path, computed by stripping the last component from the path.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readFileAsBase64({String? fileName, String? path}) Future<String?>
Reads the file and returns its content encoded as a Base64 string. Returns null when the file does not exist.
readFileAsBytes({String? fileName, String? path}) Future<Uint8List?>
Reads the file and returns its raw bytes. Returns null when the file does not exist.
readFileAsString({String? fileName, String? path}) Future<String?>
Reads the file and returns its UTF-8 content. Returns null when the file does not exist.
saveDataToDisc(Object? data, DataType dataType, {String? takeThisName, String? path, bool recursive = false}) Future<String?>
Writes data to disk.
toString() String
A string representation of this object.
inherited
validatePath(String? path) String?
Normalizes a file system path so it can be safely consumed by dart:io.

Operators

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

Static Properties

instance DiscData
Global singleton instance.
final