FileDropItem class
Unified cross-platform file, directory, or string drop reference for
file_drop.
Replaces XEntity, XFile, and XDirectory from cross_file (0.3.x and
0.4.x) as well as DropItem from desktop_drop (0.8.x and 0.9.2)
across Android, iOS, Linux, macOS, Windows, and Web/Wasm with zero external
hosted dependencies.
- Implementers
- Annotations
Constructors
- FileDropItem(String path, {String? name, String? mimeType, int? length, Uint8List? bytes, DateTime? lastModified, Uint8List? extraAppleBookmark, bool fromPromise = false, bool? isDirectory})
-
Creates a FileDropItem referencing a filesystem
path, object URL, or in-memorybytes.const - FileDropItem.fileSystem({required String path})
-
Creates a filesystem-backed FileDropItem matching
XFile.fileSystemfromcross_file 0.4.x.factory - FileDropItem.fromData(Uint8List bytes, {String? mimeType, String? path, String? name, int? length, DateTime? lastModified, Uint8List? extraAppleBookmark, bool fromPromise = false, bool? isDirectory})
-
Creates an in-memory FileDropItem backed directly by
bytes.const - FileDropItem.fromPlatformData(PlatformPickedFileData data, {Uint8List? extraAppleBookmark, bool fromPromise = false})
-
Creates a FileDropItem backed by platform-specific file metadata and a
PlatformPickedFileDatahandle (such as a browserBlobor Androidcontent://URI).factory - FileDropItem.fromUri(Uri uri)
-
Creates a FileDropItem from a
file://,content://, orblob:uri.factory
Properties
- appleBookmark → Uint8List?
-
Alias for extraAppleBookmark matching
desktop_drop 0.9.2.no setter - extraAppleBookmark → Uint8List?
-
Optional macOS security-scoped bookmark data when dropped from outside
the application sandbox container.
final
- file → FileDropItem
-
Self-reference matching
DropFileItem.fileindesktop_drop 0.9.2.no setter - fromPromise → bool
-
Whether this item was materialized from a native file promise into a
temporary drop folder.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isDirectory → bool
-
Whether this item represents a directory.
no setter
- isPromised → bool
-
Alias for fromPromise matching
desktop_drop 0.9.2.no setter - localPath → String?
-
Local filesystem path when backed by a local file or directory, or
nullon Web, Androidcontent://URIs, and purely in-memory items (desktop_drop 0.9.2parity).no setter - mimeType → String?
-
Optional MIME type explicitly supplied at construction time.
final
- name → String
-
The base filename or directory name extracted from path across both
POSIX (
/) and Windows (\) path separators.no setter - path → String
-
The filesystem path,
content://URI, or Web object URL of this item, or an empty string if created purely from in-memory bytes or string data.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- uri → String
-
URI representation of path matching
XEntity.uriincross_file 0.4.x.no setter
Methods
-
exists(
) → Future< bool> -
Returns whether the referenced file or directory exists (
XEntity.existsparity forcross_file 0.4.x). -
lastModified(
) → Future< DateTime> - Returns the last-modified timestamp of the file.
-
length(
) → Future< int> - Returns the length of the file in bytes.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
openRead(
[int? start, int? end]) → Stream< Uint8List> -
Opens an independent byte Stream over the file contents from
start(inclusive) toend(exclusive). -
readAsBytes(
) → Future< Uint8List> - Reads the entire file contents as a Uint8List.
-
readAsString(
{Encoding encoding = utf8}) → Future< String> -
Reads the entire file contents decoded using
encoding(defaults to utf8). -
saveTo(
String targetPath) → Future< void> -
Copies, writes, or downloads the contents of this item to
targetPath. -
toString(
) → String -
A string representation of this object.
override
-
writeAsBytes(
Uint8List bytes) → Future< FileDropItem> -
Writes
bytesto path (or triggers a browser download on Web) and returns an updated FileDropItem (FileSystemXFile.writeAsBytesparity forcross_file 0.4.x).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited