From c8ba5cba3b43547825ace11459e94a864186bd71 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Thu, 7 May 2026 12:53:16 +0500 Subject: [PATCH 1/4] Document native mimeType behavior in cross_file --- packages/cross_file/README.md | 7 +++++++ packages/cross_file/lib/src/types/base.dart | 4 ++++ packages/cross_file/lib/src/types/io.dart | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/packages/cross_file/README.md b/packages/cross_file/README.md index 290295571877..df5a96044af0 100644 --- a/packages/cross_file/README.md +++ b/packages/cross_file/README.md @@ -25,6 +25,13 @@ print('Content of the file: $fileContent'); You will find links to the API docs on the [pub page](https://pub.dev/packages/cross_file). +## MIME types + +On web, `mimeType` reflects browser-provided file metadata when available. +Native implementations do not infer MIME types from file paths or contents. +On native platforms, `mimeType` returns the value explicitly passed to the +`XFile` constructor or `XFile.fromData`, if any. + ## Web Limitations `XFile` on the web platform is backed by [Blob](https://api.dart.dev/be/180361/dart-html/Blob-class.html) diff --git a/packages/cross_file/lib/src/types/base.dart b/packages/cross_file/lib/src/types/base.dart index b3fb82ea4063..4e5f7a19a1af 100644 --- a/packages/cross_file/lib/src/types/base.dart +++ b/packages/cross_file/lib/src/types/base.dart @@ -46,6 +46,10 @@ abstract class XFileBase { } /// For web, it may be necessary for a file to know its MIME type. + /// + /// Native implementations do not infer this value from the file path or + /// contents. On those platforms, this returns the value passed to the + /// constructor, if any. String? get mimeType { throw UnimplementedError('.mimeType has not been implemented.'); } diff --git a/packages/cross_file/lib/src/types/io.dart b/packages/cross_file/lib/src/types/io.dart index c1931a743a89..deaf7bc18646 100644 --- a/packages/cross_file/lib/src/types/io.dart +++ b/packages/cross_file/lib/src/types/io.dart @@ -24,6 +24,9 @@ class XFile extends XFileBase { /// [length] is ignored; the parameter exists only to match the web version of /// the constructor. /// + /// [mimeType] is not inferred from [path]. It is returned from [mimeType] only + /// if it is explicitly provided. + /// // ignore: use_super_parameters XFile( String path, { @@ -42,6 +45,8 @@ class XFile extends XFileBase { /// /// [name] is ignored; the parameter exists only to match the web version of /// the constructor. + /// + /// [mimeType] is returned from [mimeType] only if it is explicitly provided. XFile.fromData( Uint8List bytes, { String? mimeType, From 24646a4439e3b72abb0e1d622aedfcd8f5661dc7 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Thu, 7 May 2026 13:11:58 +0500 Subject: [PATCH 2/4] Update packages/cross_file/lib/src/types/io.dart Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/cross_file/lib/src/types/io.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cross_file/lib/src/types/io.dart b/packages/cross_file/lib/src/types/io.dart index deaf7bc18646..21e0db2deed0 100644 --- a/packages/cross_file/lib/src/types/io.dart +++ b/packages/cross_file/lib/src/types/io.dart @@ -46,7 +46,7 @@ class XFile extends XFileBase { /// [name] is ignored; the parameter exists only to match the web version of /// the constructor. /// - /// [mimeType] is returned from [mimeType] only if it is explicitly provided. + /// The [mimeType] property returns the value explicitly provided here, if any. XFile.fromData( Uint8List bytes, { String? mimeType, From 5b726c66a8411026b816c8a3b402193c15300f26 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Fri, 8 May 2026 14:18:41 +0500 Subject: [PATCH 3/4] Update packages/cross_file/lib/src/types/base.dart Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/cross_file/lib/src/types/base.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cross_file/lib/src/types/base.dart b/packages/cross_file/lib/src/types/base.dart index 4e5f7a19a1af..a9031a1f3a6c 100644 --- a/packages/cross_file/lib/src/types/base.dart +++ b/packages/cross_file/lib/src/types/base.dart @@ -49,7 +49,7 @@ abstract class XFileBase { /// /// Native implementations do not infer this value from the file path or /// contents. On those platforms, this returns the value passed to the - /// constructor, if any. + /// implementation's constructor, if any. String? get mimeType { throw UnimplementedError('.mimeType has not been implemented.'); } From 11f0e45a5e6e41eab53fc3064dd56b99d8564252 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Fri, 8 May 2026 14:18:49 +0500 Subject: [PATCH 4/4] Update packages/cross_file/lib/src/types/io.dart Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/cross_file/lib/src/types/io.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cross_file/lib/src/types/io.dart b/packages/cross_file/lib/src/types/io.dart index 21e0db2deed0..c6af0487dcb9 100644 --- a/packages/cross_file/lib/src/types/io.dart +++ b/packages/cross_file/lib/src/types/io.dart @@ -24,8 +24,8 @@ class XFile extends XFileBase { /// [length] is ignored; the parameter exists only to match the web version of /// the constructor. /// - /// [mimeType] is not inferred from [path]. It is returned from [mimeType] only - /// if it is explicitly provided. + /// [mimeType] is not inferred from [path]. The [mimeType] property returns the + /// value explicitly provided here, if any. /// // ignore: use_super_parameters XFile(