flutter_file_picker/lib/src/platform_file.dart

45 lines
1.3 KiB
Dart
Raw Normal View History

import 'dart:async';
import 'dart:typed_data';
class PlatformFile {
const PlatformFile({
required this.name,
required this.size,
this.path,
this.bytes,
this.readStream,
});
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
/// The absolute path for a cached copy of this file. It can be used to create a
/// file instance with a descriptor for the given path.
/// ```
/// final File myFile = File(platformFile.path);
/// ```
/// On web this is always `null`. You should access `bytes` property instead.
/// Read more about it [here](https://github.com/miguelpruivo/flutter_file_picker/wiki/FAQ)
2020-11-21 21:26:32 +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.
/// [Check here in the FAQ](https://github.com/miguelpruivo/flutter_file_picker/wiki/FAQ) an example on how to use it to upload on web.
2020-11-21 21:26:32 +00:00
final Uint8List? bytes;
/// File content as stream
2020-11-21 21:26:32 +00:00
final Stream<List<int>>? readStream;
/// The file size in bytes.
final int size;
2020-09-09 23:52:45 +00:00
/// File extension for this file.
String? get extension => name.split('.').last;
}