Skip to content

Clarify PlatformException code, message, and details docs - #194293

Open
Arefin-Himu wants to merge 1 commit into
flutter:masterfrom
Arefin-Himu:74352-platformexception-docs
Open

Arefin-Himu wants to merge 1 commit into
flutter:masterfrom
Arefin-Himu:74352-platformexception-docs

Conversation

@Arefin-Himu

Copy link
Copy Markdown

Clarifies the PlatformException API documentation in packages/flutter/lib/src/services/message_codec.dart. This contribution changes documentation comments only and does not alter runtime behavior.

The changes improve the documentation in three areas:

  • code: Explains that the error code is supplied by the code reporting the error and that any String can be used.
  • message: Clarifies that the reporting code is not required to provide a message.
  • details: Explains that the details are supplied by the reporting code and must be supported by the channel's MethodCodec. For the default StandardMethodCodec, it refers readers to the supported values documented with StandardMessageCodec.

The change also removes the extra comma from each of the three relevant “See also” entries, as requested in [#74352](#74352).

Scope: This contribution addresses only part of the issue. It does not add examples or fully address when message or stacktrace should be null; those aspects remain outside this change.

Validation

  • Passed locally on October 11, 2026, using the Dart SDK pinned by this branch's base:
    • git diff --check
    • dart format --output=none --set-exit-if-changed
    • dart analyze --fatal-infos on message_codec.dart, with no issues found.
  • Documentation-reference check: A read-only check using the committed file and updated upstream foundation files resolved 41 references with zero unresolved references. This was not a full Dartdoc build.
  • Not run: dev/bots/analyze.dart, the full test suite, and the full documentation build.
  • Formatting and analysis have not been rerun with the newer Dart SDK currently pinned on upstream master.
  • Tests: No tests were added because this change affects documentation comments only. Flutter's [Tree Hygiene guide](https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests) lists comment-only changes as test-exempt; reviewers may still request tests.

Pre-launch Checklist

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

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). 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.

The PlatformException field docs did not explain where the error code
comes from, why the message can be null, or which values the details
can hold, and the three "See also" entries each had an extra comma.

Document that the error code and details are supplied by the code that
reports the error, that any String can be used as an error code, that
a message is optional, and that details must be supported by the
channel's MethodCodec (for the default StandardMethodCodec, the values
documented with StandardMessageCodec). Remove the extra commas.

Part of flutter#74352
@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Oct 13, 2026

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

Copy link
Copy Markdown
Contributor

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 comments for the PlatformException class in message_codec.dart by adjusting punctuation and adding descriptions for the code, message, and details fields. A review comment suggests using square brackets instead of backticks for StandardMethodCodec and StandardMessageCodec to enable proper Dartdoc cross-linking.

Comment on lines +128 to +130
/// value must be supported by the [MethodCodec] used by the channel; for the
/// default `StandardMethodCodec`, the supported values are documented with
/// `StandardMessageCodec`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To ensure proper API documentation generation and cross-linking, refer to StandardMethodCodec and StandardMessageCodec using square brackets (e.g., [StandardMethodCodec] and [StandardMessageCodec]) instead of backticks. This allows Dartdoc to generate hyperlinks to their respective documentation.

Suggested change
/// value must be supported by the [MethodCodec] used by the channel; for the
/// default `StandardMethodCodec`, the supported values are documented with
/// `StandardMessageCodec`.
/// value must be supported by the [MethodCodec] used by the channel; for the
/// default [StandardMethodCodec], the supported values are documented with
/// [StandardMessageCodec].
References
  1. Introduce terms: Assume the reader does not know everything. Link to definitions. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant