XFile class

A CrossFile is a cross-platform, simplified File abstraction.

It wraps the bytes of a selected file, and its (platform-dependant) path.

Available extensions

Constructors

XFile(String path, {String? mimeType, String? name, int? length, Uint8List? bytes, DateTime? lastModified, @visibleForTesting CrossFileTestOverrides? overrides})
Construct a CrossFile object from its path.
XFile.fromData(Uint8List bytes, {String? mimeType, String? name, int? length, DateTime? lastModified, String? path, @visibleForTesting CrossFileTestOverrides? overrides})
Construct a CrossFile object from its data

Properties

asImageFile Future<ImageFile>

Available on XFile, provided by the XFileExtension extension

no setter
hashCode int
The hash code for this object.
no setterinherited
mimeType String?
For web, it may be necessary for a file to know its MIME type.
no setterinherited
name String
The name of the file as it was selected by the user in their device.
no setterinherited
path String
Get the path of the picked file.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

lastModified() Future<DateTime>
Get the last-modified time for the CrossFile
inherited
length() Future<int>
Get the length of the file. Returns a Future<int> that completes with the length in bytes.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openRead([int? start, int? end]) Stream<Uint8List>
Create a new independent Stream for the contents of this file.
inherited
readAsBytes() Future<Uint8List>
Asynchronously read the entire file contents as a list of bytes.
inherited
readAsString({Encoding encoding = utf8}) Future<String>
Asynchronously read the entire file contents as a string using the given Encoding.
inherited
saveTo(String path) Future<void>
Save the CrossFile at the indicated file path.
inherited
toString() String
A string representation of this object.
inherited

Operators

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