2020-09-07 19:06:18 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
class PlatformFile {
|
2020-09-11 13:53:18 +00:00
|
|
|
const PlatformFile({
|
2020-09-07 19:06:18 +00:00
|
|
|
this.path,
|
|
|
|
this.uri,
|
|
|
|
this.name,
|
|
|
|
this.bytes,
|
2020-09-09 23:52:45 +00:00
|
|
|
this.size,
|
2020-09-07 19:06:18 +00:00
|
|
|
this.isDirectory = false,
|
|
|
|
});
|
|
|
|
|
2020-09-09 23:52:45 +00:00
|
|
|
PlatformFile.fromMap(Map data)
|
|
|
|
: this.path = data['path'],
|
|
|
|
this.uri = data['uri'],
|
|
|
|
this.name = data['name'],
|
|
|
|
this.bytes = data['bytes'],
|
|
|
|
this.size = data['size'],
|
|
|
|
this.isDirectory = data['isDirectory'];
|
|
|
|
|
|
|
|
/// The absolute path for a cached copy of this file.
|
|
|
|
/// If you want to access the original file identifier use [uri] property instead.
|
2020-09-07 19:06:18 +00:00
|
|
|
final String path;
|
|
|
|
|
|
|
|
/// The URI (Universal Resource Identifier) for this file.
|
|
|
|
///
|
2020-09-09 23:52:45 +00:00
|
|
|
/// This is the identifier of original resource and can be used to
|
2020-09-07 19:06:18 +00:00
|
|
|
/// manipulate the original file (read, write, delete).
|
|
|
|
///
|
2020-09-09 23:52:45 +00:00
|
|
|
/// Android: it can be either content:// or file:// url.
|
2020-09-11 13:53:18 +00:00
|
|
|
///
|
2020-09-09 23:52:45 +00:00
|
|
|
/// iOS: a file:// URL below a document provider (like iCloud).
|
2020-09-11 13:53:18 +00:00
|
|
|
///
|
2020-09-09 23:52:45 +00:00
|
|
|
/// Web: Not supported, will be always `null`.
|
2020-09-07 19:06:18 +00:00
|
|
|
final String uri;
|
|
|
|
|
|
|
|
/// File name including its extension.
|
|
|
|
final String name;
|
|
|
|
|
2020-09-09 23:52:45 +00:00
|
|
|
/// Byte data for this file. Particurlarly useful if you want to manipulate its data
|
|
|
|
/// or easily upload to somewhere else.
|
2020-09-07 19:06:18 +00:00
|
|
|
final Uint8List bytes;
|
|
|
|
|
2020-09-09 23:52:45 +00:00
|
|
|
/// The file size in KB.
|
|
|
|
final int size;
|
|
|
|
|
2020-09-07 19:06:18 +00:00
|
|
|
/// Whether this file references a directory or not.
|
|
|
|
final bool isDirectory;
|
|
|
|
|
|
|
|
/// File extension for this file.
|
2020-09-11 13:53:18 +00:00
|
|
|
String get extension => name?.split('/')?.last;
|
2020-09-07 19:06:18 +00:00
|
|
|
}
|