From 3f3a2ca8013cfe265973c2318667a6c84b8037e0 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Thu, 7 May 2026 12:53:16 +0500 Subject: [PATCH 1/5] 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 4095eb76cc0f47880a49b32bf7e913fd35607f5f Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Thu, 7 May 2026 13:11:58 +0500 Subject: [PATCH 2/5] 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 a266c32c3915f8f6e60f39d819d72ec2c945302b Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Fri, 8 May 2026 14:18:41 +0500 Subject: [PATCH 3/5] 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 0e88ccb34bfb6229d968fdaea24d9273d89d8224 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Fri, 8 May 2026 14:18:49 +0500 Subject: [PATCH 4/5] 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( From b556bd38374473cd2b0ea62b3ce2f5312d856498 Mon Sep 17 00:00:00 2001 From: Faheem Abbas Date: Mon, 1 Jun 2026 14:42:16 +0500 Subject: [PATCH 5/5] Update cross_file release info --- packages/cross_file/CHANGELOG.md | 3 ++- packages/cross_file/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cross_file/CHANGELOG.md b/packages/cross_file/CHANGELOG.md index 8e43e986429c..e4e29a8fbcf4 100644 --- a/packages/cross_file/CHANGELOG.md +++ b/packages/cross_file/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 0.3.5+3 +* Clarifies native XFile.mimeType documentation. * Updates minimum supported SDK version to Flutter 3.38/Dart 3.10. ## 0.3.5+2 diff --git a/packages/cross_file/pubspec.yaml b/packages/cross_file/pubspec.yaml index 46a59f1a7cda..d0bb7119f1f2 100644 --- a/packages/cross_file/pubspec.yaml +++ b/packages/cross_file/pubspec.yaml @@ -2,7 +2,7 @@ name: cross_file description: An abstraction to allow working with files across multiple platforms. repository: https://github.com/flutter/packages/tree/main/packages/cross_file issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+cross_file%22 -version: 0.3.5+2 +version: 0.3.5+3 environment: sdk: ^3.10.0