Skip to content

[Semantics] clarify Android header docs#183573

Merged
auto-submit[bot] merged 6 commits into
flutter:masterfrom
mayanksharma9:fix-183111-semantics-header-docs
Apr 8, 2026
Merged

[Semantics] clarify Android header docs#183573
auto-submit[bot] merged 6 commits into
flutter:masterfrom
mayanksharma9:fix-183111-semantics-header-docs

Conversation

@mayanksharma9

Copy link
Copy Markdown
Contributor

Clarifies the SemanticsProperties.header API docs for Android.

Issue

The current documentation says that header marks a subtree as a header, but it does not explain that Android accessibility does not expose a separate header concept. In practice, header: true alone is not enough for TalkBack to treat the content as a heading on Android.

This led to confusion in #183111, where the behavior looked inconsistent across platforms even though the framework behavior is currently working as intended.

What changed

Updated the SemanticsProperties.header documentation to explain that:

  • Android accessibility exposes headings rather than a separate header concept
  • header alone is not sufficient on Android
  • callers should also set headingLevel when they want heading semantics on Android

Outcome

The API docs now describe the platform-specific behavior more accurately, so developers can understand why header behaves differently on Android and how to mark headings correctly there.

Fixes #183111

Pre-launch Checklist

Tests

  • ../../bin/dart analyze lib/src/semantics/semantics.dart
  • ../../bin/flutter test test/widgets/semantics_test.dart --plain-name "Semantics widget supports all flags"

@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) labels Mar 12, 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 for SemanticsProperties.header to clarify its behavior on Android. The change explains that setting header: true is not sufficient on its own and that the headingLevel property must also be set to correctly mark a heading for Android accessibility services. It also includes a minor wording improvement for better clarity.

Comment on lines +1804 to +1807
/// Support for this semantic varies by platform. Android accessibility
/// exposes headings rather than a separate header concept, so `header` alone
/// is not sufficient there. To mark content as a heading on Android, also set
/// [headingLevel].

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 improve readability, consider rephrasing this paragraph. The current wording is a bit dense and could be more direct about why headingLevel is necessary on Android.

/// Support for this semantic varies by platform. On Android, this property
/// alone is not sufficient. To mark content as a heading for accessibility
/// services, also set [headingLevel]. This is because Android's accessibility
/// APIs expose headings, but not a separate header concept.
References
  1. The style guide emphasizes optimizing for readability and providing useful documentation that explains the 'why' and 'how'. This suggestion aims to make the explanation clearer. (link)

@mayanksharma9

Copy link
Copy Markdown
Contributor Author

Good call on readability. I pushed 84f728f6208 to simplify that paragraph and make the Android requirement for headingLevel more direct.

@mayanksharma9

Copy link
Copy Markdown
Contributor Author

Correction on the commit id in my previous note. The pushed commit is 9399c63.

@Piinks Piinks requested a review from chunhtai March 17, 2026 22:35
/// A header divides into sections. For example, an address book application
/// might define headers A, B, C, etc. to divide the list of alphabetically
/// sorted contacts into sections.
/// A header divides content into sections. For example, an address book

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.

The original doc is inaccurate, this paragraph describes heading, should move this to the heading property.

header is usually the top element of a page, for example, a title or app bar of a page.

/// application might define headers A, B, C, etc. to divide the list of
/// alphabetically sorted contacts into sections.
///
/// Support for this semantic varies by platform. On Android, this property

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.

this flag is not supported in Android, as Android don't have a notion of header in its assistive technologies

@mayanksharma9

Copy link
Copy Markdown
Contributor Author

Thanks, this is helpful. I agree the docs are mixing header vs heading semantics right now. I’ll move the Android-specific heading guidance under and tighten the docs so they describe the top-of-page concept clearly.

@mayanksharma9

Copy link
Copy Markdown
Contributor Author

Follow-up (my last comment got formatting-mangled by CLI quoting): I’ll move the Android-specific guidance to headingLevel, and keep header docs focused on top-of-page/header semantics.

@mayanksharma9

Copy link
Copy Markdown
Contributor Author

Applied. I updated the docs so now describes top-of-page/section header semantics, and moved Android heading guidance to . Pushed in c4a172c.

@mayanksharma9

Copy link
Copy Markdown
Contributor Author

Follow-up to fix formatting in my previous comment: docs updated so header now describes top-of-page/section header semantics, and Android heading guidance now lives under headingLevel. Pushed in c4a172c.

@@ -2232,6 +2226,9 @@ class SemanticsProperties extends DiagnosticableTree {
///
/// On web, this sets the `aria-level` attribute (e.g., `aria-level="1"`).
/// On Android, this sets the `isHeading` property for accessibility.
///
/// Android accessibility does not expose a separate "header" semantic, so

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.

this doesn't need to mention header, just move the old doc here. and we don't need to mention android here because this is supported for multiple platforms

 /// A heading divides into sections. For example, an address book application
  /// might define heading A, B, C, etc. to divide the list of alphabetically
  /// sorted contacts into sections.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good call. I moved that section wording to headingLevel and removed the Android specific header note there. Updated in 421f2f0.

@stuartmorgan-g

Copy link
Copy Markdown
Contributor

Note to reviewers: this user appears to be running an unsupervised or poorly-supervised agent, and has received a warning and temporary ban. If interaction resumes next week, approach the review with caution.

@chunhtai chunhtai self-requested a review April 1, 2026 21:42

@chunhtai chunhtai 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.

LGTM

@chunhtai chunhtai added CICD Run CI/CD autosubmit Merge PR when tree becomes green via auto submit App labels Apr 6, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 6, 2026
@auto-submit

auto-submit Bot commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/flutter/183573, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@justinmc justinmc 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.

LGTM 👍

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 7, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Apr 8, 2026
Merged via the queue into flutter:master with commit 06d5086 Apr 8, 2026
83 of 84 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 8, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 8, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Apr 8, 2026
flutter/flutter@a0924c7...05e0ae0

2026-04-08 [email protected] Fix Android engine flags defaulting to true for malformed values (flutter/flutter#184631)
2026-04-08 [email protected] Try one more again (flutter/flutter#184767)
2026-04-08 [email protected] Remove custom `analysis_options.yaml` from `imitation_game_flutter` (flutter/flutter#184717)
2026-04-08 [email protected] Add more error handling to unawaited callsites (flutter/flutter#184526)
2026-04-08 [email protected] Refactor: remove material from absorb_ponter_test, container_test,  lookup_boundary_test, page_view_test, router_test, semantics_clipping_test, semantics_merge_test, shadow_test, text_test (flutter/flutter#183309)
2026-04-08 [email protected] Remove editable_text_utils cross-imports from material and cupertino … (flutter/flutter#184519)
2026-04-08 [email protected] Replace hard coded max path length with system defined one. (flutter/flutter#184697)
2026-04-08 [email protected] [Re-land] Add Support For Built-in Kotlin (flutter/flutter#184745)
2026-04-08 [email protected] Manually stop and continue LLDB breakpoints on Xcode 26.4+ (flutter/flutter#184690)
2026-04-08 [email protected] Code freeze workflow (flutter/flutter#184246)
2026-04-08 [email protected] [Dot shorthands] Migrate examples/api/lib/widgets (flutter/flutter#183965)
2026-04-08 [email protected] [cupertino.dart] Implement CupertinoMenuAnchor and CupertinoMenuItem using RawMenuAnchor (flutter/flutter#182036)
2026-04-08 [email protected] [Semantics] clarify Android header docs (flutter/flutter#183573)
2026-04-08 [email protected] [ci] mac build_test bringup false (flutter/flutter#184738)
2026-04-08 [email protected] Reland "Apply rect clipping to surface views" (flutter/flutter#184732)
2026-04-08 [email protected] Remove bringup label for resharded Windows tool_integration_tests shards (flutter/flutter#184721)
2026-04-08 [email protected] Tool: Add search and filtering to widget preview scaffold (flutter/flutter#184023)
2026-04-08 [email protected] Update localization from translation console (flutter/flutter#184742)
2026-04-07 [email protected] Revert "Add Support For Built-in Kotlin (#184227)" (flutter/flutter#184739)
2026-04-07 [email protected] Collect HCPP adoption analytics for flutter run/build apk/build appbundle (flutter/flutter#184225)
2026-04-07 [email protected] Add a github workflow for reverting PRs. (flutter/flutter#184593)
2026-04-07 [email protected] Add Support For Built-in Kotlin (flutter/flutter#184227)
2026-04-07 [email protected] Revert "Apply rect clipping to surface views (#184471)" (flutter/flutter#184728)
2026-04-07 [email protected] [Fix-forward] Added Compose plugin to Add-to-app Integration Test (flutter/flutter#184681)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
mbcorona pushed a commit to mbcorona/flutter that referenced this pull request Apr 15, 2026
Clarifies the `SemanticsProperties.header` API docs for Android.

## Issue

The current documentation says that `header` marks a subtree as a
header, but it does not explain that Android accessibility does not
expose a separate header concept. In practice, `header: true` alone is
not enough for TalkBack to treat the content as a heading on Android.

This led to confusion in flutter#183111, where the behavior looked inconsistent
across platforms even though the framework behavior is currently working
as intended.

## What changed

Updated the `SemanticsProperties.header` documentation to explain that:

- Android accessibility exposes headings rather than a separate header
concept
- `header` alone is not sufficient on Android
- callers should also set `headingLevel` when they want heading
semantics on Android

## Outcome

The API docs now describe the platform-specific behavior more
accurately, so developers can understand why `header` behaves
differently on Android and how to mark headings correctly there.

Fixes flutter#183111

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

## Tests

- `../../bin/dart analyze lib/src/semantics/semantics.dart`
- `../../bin/flutter test test/widgets/semantics_test.dart --plain-name
"Semantics widget supports all flags"`

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: chunhtai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update semantics header property that it isn't supported on Android.

4 participants