Skip to content

Clarify cross_file MIME type docs#11727

Draft
mackings wants to merge 1 commit into
flutter:mainfrom
mackings:docs-cross-file-mimetype
Draft

Clarify cross_file MIME type docs#11727
mackings wants to merge 1 commit into
flutter:mainfrom
mackings:docs-cross-file-mimetype

Conversation

@mackings
Copy link
Copy Markdown

Clarifies the cross_file documentation for XFile.mimeType.

This PR documents that mimeType is not inferred from the file path or file contents. It is only available when provided while creating the XFile, or when available from the platform-backed file.

Fixes flutter/flutter#93379

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful, you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for XFile to clarify that the mimeType property is not automatically inferred from file paths or contents. These updates are reflected in the CHANGELOG.md, README.md, and the base and IO implementations of XFile. Feedback was provided to improve the clarity of the documentation in the XFile constructors by explicitly stating that the mimeType is only available if passed to the constructor, and to ensure consistency by applying similar updates to the HTML implementation.

Comment on lines +27 to +28
/// [mimeType] is not inferred from [path] and is returned from [mimeType]
/// only if explicitly passed.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The phrasing "returned from [mimeType]" is confusing because [mimeType] is used for both the parameter and the property in this context. It would be clearer to state that the property is only available if the parameter is provided. Additionally, for consistency, please consider applying similar documentation updates to the XFile constructors in lib/src/types/html.dart.

Suggested change
/// [mimeType] is not inferred from [path] and is returned from [mimeType]
/// only if explicitly passed.
/// [mimeType] is not inferred from [path] and is only available if explicitly
/// passed to the constructor.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the wording in io.dart and added matching constructor documentation in html.dart. Tests still pass.


/// Construct an CrossFile from its data
///
/// [mimeType] is returned from [mimeType] only if explicitly passed.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The phrasing "returned from [mimeType]" is redundant. It's clearer to specify that the value is only available if provided during construction.

Suggested change
/// [mimeType] is returned from [mimeType] only if explicitly passed.
/// [mimeType] is only available if explicitly passed to the constructor.

@mackings mackings force-pushed the docs-cross-file-mimetype branch from ddb605b to 1a79271 Compare May 18, 2026 09:37
@stuartmorgan-g
Copy link
Copy Markdown
Collaborator

Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the state of the PR as posted reflects the checklist please feel free to mark it as ready for review.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft May 18, 2026 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cross_file] Document that mimeType is not expected to be set for io implementation

2 participants