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
datato an existing file on disk. -
checkFileExists(
{String? fileName, String? path}) → Future< bool> -
Returns
trueif the file identified byfileName(relative to filesPath) or by the absolutepathexists 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
nullwhen 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
nullwhen the file does not exist. -
readFileAsBytes(
{String? fileName, String? path}) → Future< Uint8List?> -
Reads the file and returns its raw bytes.
Returns
nullwhen the file does not exist. -
readFileAsString(
{String? fileName, String? path}) → Future< String?> -
Reads the file and returns its UTF-8 content.
Returns
nullwhen the file does not exist. -
saveDataToDisc(
Object? data, DataType dataType, {String? takeThisName, String? path, bool recursive = false}) → Future< String?> -
Writes
datato disk. -
toString(
) → String -
A string representation of this object.
inherited
-
validatePath(
String? path) → String? -
Normalizes a file system
pathso it can be safely consumed bydart:io.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited