DocumentFile class

Equivalent to Android DocumentFile class

Refer to details

Constructors

DocumentFile({required String? id, required Uri? parentUri, required int? size, required String? name, required String? type, required Uri uri, required bool? isDirectory, required bool? isFile, required bool? isVirtual, required DateTime? lastModified})
const
DocumentFile.fromMap(Map<String, dynamic> map)
factory

Properties

hashCode int
The hash code for this object.
no setteroverride
id String?
Generally represented as primary:/Some/Resource and can be used to identify the current document file.
final
isDirectory bool?
Whether this document is a directory or not.
final
isFile bool?
Indicates if this DocumentFile represents a file.
final
isVirtual bool?
Indicates if this file represents a virtual document.
final
lastModified DateTime?
Equivalent to DocumentFile.lastModified.
final
name String?
Display name of this document file, useful to show as a title in a list of files.
final
parentUri Uri?
Uri of the parent document of this document.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
size int?
Size of a document in bytes
final
type String?
Mimetype of this document file, useful to determine how to display it.
final
uri Uri
Path, URI, location of this document, it can exists or not, you should check by using exists() API.
final

Methods

canRead() Future<bool?>
Equivalent to DocumentFile.canRead.
canWrite() Future<bool?>
Equivalent to DocumentFile.canWrite.
child(String path, {bool requiresWriteAccess = false}) Future<DocumentFile?>
Return the child of the given uri if it exists otherwise null.
copy(Uri destination) Future<DocumentFile?>
Copy a document uri to the destination.
createDirectory(String displayName) Future<DocumentFile?>
Create a direct child document tree named displayName given a parent parentUri.
createFile({required String mimeType, required String displayName, String content = '', Uint8List? bytes}) Future<DocumentFile?>
Convenient method to create files using either String or raw bytes Uint8List.
createFileAsBytes({required String mimeType, required String displayName, required Uint8List bytes}) Future<DocumentFile?>
Create a direct child document of parentUri.
createFileAsString({required String mimeType, required String displayName, required String content}) Future<DocumentFile?>
Alias for createFile with content param
delete() Future<bool?>
Equivalent to DocumentFile.delete.
exists() Future<bool?>
Equivalent to DocumentFile.exists.
findFile(String displayName) Future<DocumentFile?>
Equivalent to DocumentFile.findFile.
getContent() Future<Uint8List?>
Get content of a given document uri.
getContentAsString() Future<String?>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open() Future<bool?>
Alias for openDocumentFileWithResult that returns true if the target uri was successfully launched, false otherwise.
openDocumentFile() Future<bool?>
Alias for openDocumentFileWithResult that returns true if the target uri was successfully launched, false otherwise.
parentFile() Future<DocumentFile?>
Get the parent file of the given uri.
renameTo(String displayName) Future<DocumentFile?>
Rename the current document uri to a new displayName.
toMap() Map<String, dynamic>
toString() String
A string representation of this object.
inherited
writeToFile({String? content, Uint8List? bytes, FileMode? mode}) Future<bool?>
Convenient method to write to a file using either String or raw bytes Uint8List.
writeToFileAsBytes({required Uint8List bytes, FileMode? mode}) Future<bool?>
Write to a file.
writeToFileAsString({required String content, FileMode? mode}) Future<bool?>
Alias for writeToFile with content param

Operators

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

Static Methods

fromTreeUri(Uri uri) Future<DocumentFile?>
Create a new DocumentFile instance given uri.