Skip to content

Commit 4f472f5

Browse files
committed
[cross_file] Use name if it's available.
1 parent 826fc0a commit 4f472f5

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • packages/cross_file/lib/src/types

‎packages/cross_file/lib/src/types/io.dart‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class XFile extends XFileBase {
3636
_file = File(path),
3737
_bytes = null,
3838
_lastModified = lastModified,
39+
_name = name,
3940
super(path);
4041

4142
/// Construct an CrossFile from its data
@@ -54,6 +55,7 @@ class XFile extends XFileBase {
5455
_file = File(path ?? ''),
5556
_length = length,
5657
_lastModified = lastModified,
58+
_name = name,
5759
super(path) {
5860
if (length == null) {
5961
_length = bytes.length;
@@ -64,6 +66,7 @@ class XFile extends XFileBase {
6466
final String? _mimeType;
6567
final DateTime? _lastModified;
6668
int? _length;
69+
final String? _name;
6770

6871
final Uint8List? _bytes;
6972

@@ -93,7 +96,7 @@ class XFile extends XFileBase {
9396
String get path => _file.path;
9497

9598
@override
96-
String get name => _file.path.split(Platform.pathSeparator).last;
99+
String get name => _name ?? _file.path.split(Platform.pathSeparator).last;
97100

98101
@override
99102
Future<int> length() {

0 commit comments

Comments
 (0)