2020-11-12 17:28:57 +00:00
|
|
|
import 'dart:async';
|
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.name,
|
|
|
|
this.bytes,
|
2020-11-12 17:28:57 +00:00
|
|
|
this.readStream,
|
2020-09-09 23:52:45 +00:00
|
|
|
this.size,
|
2020-09-07 19:06:18 +00:00
|
|
|
});
|
|
|
|
|
2020-11-12 17:28:57 +00:00
|
|
|
PlatformFile.fromMap(Map data, {this.readStream})
|
2020-09-09 23:52:45 +00:00
|
|
|
: this.path = data['path'],
|
|
|
|
this.name = data['name'],
|
|
|
|
this.bytes = data['bytes'],
|
2020-09-11 17:37:45 +00:00
|
|
|
this.size = data['size'];
|
2020-09-09 23:52:45 +00:00
|
|
|
|
2020-09-11 17:01:34 +00:00
|
|
|
/// The absolute path for a cached copy of this file. It can be used to create a
|
|
|
|
/// a file instance with a descriptor for the given path.
|
|
|
|
/// ```
|
|
|
|
/// final File myFile = File(platformFile.path);
|
|
|
|
/// ```
|
2020-09-07 19:06:18 +00:00
|
|
|
final String path;
|
|
|
|
|
|
|
|
/// 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-11-12 17:28:57 +00:00
|
|
|
/// File content as stream
|
|
|
|
final Stream<List<int>> readStream;
|
|
|
|
|
2020-09-09 23:52:45 +00:00
|
|
|
/// The file size in KB.
|
|
|
|
final int size;
|
|
|
|
|
2020-09-07 19:06:18 +00:00
|
|
|
/// File extension for this file.
|
2020-11-11 14:42:12 +00:00
|
|
|
String get extension => name?.split('.')?.last;
|
2020-09-07 19:06:18 +00:00
|
|
|
}
|