Skip to content

Conversation

Renzo-Olivares
Copy link
Contributor

@Renzo-Olivares Renzo-Olivares commented Apr 16, 2025

Fixes #166785

Pre-launch Checklist

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

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Apr 16, 2025
@github-actions github-actions bot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels May 8, 2025
@Renzo-Olivares Renzo-Olivares force-pushed the sliver-semantics branch 4 times, most recently from 02769d5 to 7202c32 Compare May 10, 2025 00:32
@Renzo-Olivares Renzo-Olivares force-pushed the sliver-semantics branch 3 times, most recently from 432ea93 to 88b0c8a Compare June 4, 2025 20:25
@Renzo-Olivares Renzo-Olivares changed the title [WIP] SliverSemantics SliverSemantics Jun 6, 2025
@Renzo-Olivares Renzo-Olivares marked this pull request as ready for review June 6, 2025 17:45
@Renzo-Olivares Renzo-Olivares requested a review from chunhtai June 6, 2025 17:47
});

testWidgets(
'does not merge conflicting actions even if one of them is blocked with Semantics widget',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not too sure if the expected explicitChildNodes: true is the way to solve the issues with this test.

For context this test comes from:

testWidgets('does not merge conflicting actions even if one of them is blocked', (
WidgetTester tester,
) async {
final UniqueKey key = UniqueKey();
await tester.pumpWidget(
MaterialApp(
home: Semantics(
key: key,
container: true,
child: Column(
children: <Widget>[
Semantics(
blockUserActions: true,
label: 'label1',
onTap: () {},
child: const SizedBox(width: 10, height: 10),
),
Semantics(
label: 'label2',
onTap: () {},
child: const SizedBox(width: 10, height: 10),
),
],
),
),
),
);
final SemanticsNode node = tester.getSemantics(find.byKey(key));
expect(
node,
matchesSemantics(
children: <Matcher>[containsSemantics(label: 'label1'), containsSemantics(label: 'label2')],
),
);
});

In the test above the nodes under Column are not merged, but in this sliver test, the nodes under SliverList are merged, unless I use explicitChildNodes true in the SliverSemantics widget above the SliverList. I debugged and found that the cause for this is because SliverList adds semantics indexes with IndexedSemantics. If we do addSemanticIndexes: false, then this test also passes.

In the original test from semantics_test.dart if I add an IndexedSemantics around each child of the Column then we run into the same issue where the nodes under the Column are merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created an issue #170485 and updated test to use SliverToBoxAdapter -> Column for now.

@Renzo-Olivares
Copy link
Contributor Author

Google testing is failing because there already exists a SliverSemantics, I think I will try to migrate those uses to use the frameworks SliverSemantics.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

overall approach LGTM, just some suggestions to make code a bit cleaner

/// for their subtree.
mixin SemanticsAnnotationsMixin on RenderObject {
/// Initializes the semantics annotations for this mixin.
void initSemanticsAnnotations({
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is not meant to be developer facing API. I will turn all the parameter to be required just so that one day we add parameter to the list, we won't forget to update all the internal reference

/// A sliver that annotates its subtree with a description of the meaning of
/// the slivers.
///
/// Used by assistive technologies, search engines, and other semantic analysis
Copy link
Contributor

Choose a reason for hiding this comment

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

can this use template to deduplicate the doc between this and Semantics widget

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think so, but do you think both should point to the same youtube video since the video talks about the Semantics widget. They're essentially used the same way, but it may be confusing to some? What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, I think this is confusing. I think we should exclude the video out of sliver version of doc

///
/// See also:
///
/// * [SemanticsProperties], which contains a complete documentation for each
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a link to Semantics widget

Copy link
Contributor

Choose a reason for hiding this comment

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

same for the breadcumb in Semantics widget.

/// to create semantic boundaries that are either writable or not for children.
final bool explicitChildNodes;

/// Whether to replace all child semantics with this node.
Copy link
Contributor

Choose a reason for hiding this comment

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

most of this can be doc string


/// Contains properties used by assistive technologies to make the application
/// more accessible.
final SemanticsProperties properties;
Copy link
Contributor

@chunhtai chunhtai Jun 6, 2025

Choose a reason for hiding this comment

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

can any of these and the Semantics counter part to be factored out into a mixin. Asking this because adding a flag/property in semantics is already cumbersome, would appreciate we don't add another place that needs to be updated...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! I'll look into ways we can do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you think about this approach? f22a87a (#167300)

A base class used by both Semantics and SliverSemantics called SemanticsBase where SemanticsBase has its own constructor with every field marked as required. This enforces its subclasses to add that field to their constructor whenever a new one is added to SemanticsBase.

In this world, when we add a new field to SemanticsBase and mark it required, an analyzer error will appear pointing us to add the same field to its subclasses Semantics and SliverSemantics.

@Renzo-Olivares Renzo-Olivares force-pushed the sliver-semantics branch 2 times, most recently from 3e881a7 to 5587ac5 Compare June 9, 2025 22:05
@Renzo-Olivares Renzo-Olivares requested a review from chunhtai June 11, 2025 16:26
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM, would be good if we can make it private, but not blocking the pr merge

/// be enabled using [WidgetsApp.showSemanticsDebugger],
/// [MaterialApp.showSemanticsDebugger], or [CupertinoApp.showSemanticsDebugger].
/// {@endtemplate}
sealed class SemanticsBase extends SingleChildRenderObjectWidget {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for refactor this out it is a lot less duplicated code now, I wonder if this can be private? not sure whether the api doc still work if we make it private though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Confirmed the API docs still work even if we make it private.

@Renzo-Olivares
Copy link
Contributor Author

Didn't change too much besides making SemanticsBase private, and small language tweaks, API docs still work. I mainly kept the language "widgets" to be more concise, I think it still makes sense.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

still LGTM

@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Jul 8, 2025
Merged via the queue into flutter:master with commit 220477f Jul 8, 2025
70 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 8, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 9, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Jul 9, 2025
flutter/flutter@adffe24...ac12f66

2025-07-09 engine-flutter-autoroll@skia.org Roll Packages from cba2e90 to 4a231ae (5 revisions) (flutter/flutter#171879)
2025-07-09 ahmedsameha1@gmail.com Replace [FinderBase] with [Finder] in the documentation of Matchers (flutter/flutter#168279)
2025-07-09 mdebbar@google.com Revert "Mark web_long_running_tests_2_5 as bringup" (flutter/flutter#171872)
2025-07-09 bruno.leroux@gmail.com Apply normalization to TimePickerThemeData.inputDecorationTheme (flutter/flutter#171584)
2025-07-09 bruno.leroux@gmail.com Fix InputDecorationThemeData.activeIndicatorBorder is not applied (flutter/flutter#171764)
2025-07-09 robert.ancell@canonical.com Fix multi-view GL rendering not working since software rendering was added (flutter/flutter#171409)
2025-07-09 fluttergithubbot@gmail.com Marks Linux_android_emu android_engine_vulkan_tests to be unflaky (flutter/flutter#171141)
2025-07-08 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from AinHuT0vgOelA1g7_... to 0-xqmXWc4cXzw3tfe... (flutter/flutter#171823)
2025-07-08 fluttergithubbot@gmail.com Marks Linux_android_emu android_display_cutout to be unflaky (flutter/flutter#171140)
2025-07-08 1063596+reidbaker@users.noreply.github.com [Documentation] When updating kgp minimum document additional changes that are required (flutter/flutter#171819)
2025-07-08 fluttergithubbot@gmail.com Marks Linux_android_emu android_engine_opengles_tests to be unflaky (flutter/flutter#171142)
2025-07-08 biggs0125@gmail.com Add support for running dart2wasm in dry run mode on js compilations (flutter/flutter#171682)
2025-07-08 matanlurey@users.noreply.github.com Remove now duplicate un-forward ports for Android (flutter/flutter#171473)
2025-07-08 kjlubick@users.noreply.github.com [skia] Update usage of removed gn flag (flutter/flutter#171800)
2025-07-08 mdebbar@google.com [web] Disable auto-formatting for the stack_trace.dart test file (flutter/flutter#171801)
2025-07-08 1063596+reidbaker@users.noreply.github.com Bump warn and error versions of agp, kotlin and gradle versions in preparation for gradle 9 (flutter/flutter#171776)
2025-07-08 63253361+Phantom-101@users.noreply.github.com Removed string keys (flutter/flutter#171293)
2025-07-08 32538273+ValentinVignal@users.noreply.github.com Add `radioSide` to `RadioListTile` (flutter/flutter#171318)
2025-07-08 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from ZpnML-jis0gVIvtx5... to MnFlN7VWM_7h7EmBV... (flutter/flutter#171787)
2025-07-08 matanlurey@users.noreply.github.com Add/use `addMachineOutputFlag`/`outputsMachineFormat` instead of strings (flutter/flutter#171459)
2025-07-08 36861262+QuncCccccc@users.noreply.github.com Update translation from console (flutter/flutter#171556)
2025-07-08 bkonyi@google.com [ Tool ] Support upgrading to a new Flutter version pointing to the same revision as a previous version (flutter/flutter#171783)
2025-07-08 matej.knopp@gmail.com Multi-window support (engine) (flutter/flutter#168728)
2025-07-08 34269530+PrimaelQuemerais@users.noreply.github.com Fixes an issue where TapRegion would consume taps regardless of navigation state (flutter/flutter#169067)
2025-07-08 rmolivares@renzo-olivares.dev SliverSemantics (flutter/flutter#167300)
2025-07-08 engine-flutter-autoroll@skia.org Roll Skia from e159882c6ce0 to 0fef076beec3 (3 revisions) (flutter/flutter#171779)
2025-07-08 mdebbar@google.com Run hot_restart_web_amd_test.dart on Mac/Windows (flutter/flutter#171281)
2025-07-08 engine-flutter-autoroll@skia.org Roll Packages from 2c52f24 to cba2e90 (2 revisions) (flutter/flutter#171775)

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 louisehsu@google.com,stuartmorgan@google.com 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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 9, 2025
Fixes flutter#166785 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.

---------

Co-authored-by: Renzo Olivares <roliv@google.com>
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
Fixes flutter#166785 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.

---------

Co-authored-by: Renzo Olivares <roliv@google.com>
azatech pushed a commit to azatech/flutter that referenced this pull request Jul 28, 2025
Fixes flutter#166785 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.

---------

Co-authored-by: Renzo Olivares <roliv@google.com>
vashworth pushed a commit to vashworth/packages that referenced this pull request Jul 30, 2025
…r#9584)

flutter/flutter@adffe24...ac12f66

2025-07-09 engine-flutter-autoroll@skia.org Roll Packages from cba2e90 to 4a231ae (5 revisions) (flutter/flutter#171879)
2025-07-09 ahmedsameha1@gmail.com Replace [FinderBase] with [Finder] in the documentation of Matchers (flutter/flutter#168279)
2025-07-09 mdebbar@google.com Revert "Mark web_long_running_tests_2_5 as bringup" (flutter/flutter#171872)
2025-07-09 bruno.leroux@gmail.com Apply normalization to TimePickerThemeData.inputDecorationTheme (flutter/flutter#171584)
2025-07-09 bruno.leroux@gmail.com Fix InputDecorationThemeData.activeIndicatorBorder is not applied (flutter/flutter#171764)
2025-07-09 robert.ancell@canonical.com Fix multi-view GL rendering not working since software rendering was added (flutter/flutter#171409)
2025-07-09 fluttergithubbot@gmail.com Marks Linux_android_emu android_engine_vulkan_tests to be unflaky (flutter/flutter#171141)
2025-07-08 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from AinHuT0vgOelA1g7_... to 0-xqmXWc4cXzw3tfe... (flutter/flutter#171823)
2025-07-08 fluttergithubbot@gmail.com Marks Linux_android_emu android_display_cutout to be unflaky (flutter/flutter#171140)
2025-07-08 1063596+reidbaker@users.noreply.github.com [Documentation] When updating kgp minimum document additional changes that are required (flutter/flutter#171819)
2025-07-08 fluttergithubbot@gmail.com Marks Linux_android_emu android_engine_opengles_tests to be unflaky (flutter/flutter#171142)
2025-07-08 biggs0125@gmail.com Add support for running dart2wasm in dry run mode on js compilations (flutter/flutter#171682)
2025-07-08 matanlurey@users.noreply.github.com Remove now duplicate un-forward ports for Android (flutter/flutter#171473)
2025-07-08 kjlubick@users.noreply.github.com [skia] Update usage of removed gn flag (flutter/flutter#171800)
2025-07-08 mdebbar@google.com [web] Disable auto-formatting for the stack_trace.dart test file (flutter/flutter#171801)
2025-07-08 1063596+reidbaker@users.noreply.github.com Bump warn and error versions of agp, kotlin and gradle versions in preparation for gradle 9 (flutter/flutter#171776)
2025-07-08 63253361+Phantom-101@users.noreply.github.com Removed string keys (flutter/flutter#171293)
2025-07-08 32538273+ValentinVignal@users.noreply.github.com Add `radioSide` to `RadioListTile` (flutter/flutter#171318)
2025-07-08 engine-flutter-autoroll@skia.org Roll Fuchsia Test Scripts from ZpnML-jis0gVIvtx5... to MnFlN7VWM_7h7EmBV... (flutter/flutter#171787)
2025-07-08 matanlurey@users.noreply.github.com Add/use `addMachineOutputFlag`/`outputsMachineFormat` instead of strings (flutter/flutter#171459)
2025-07-08 36861262+QuncCccccc@users.noreply.github.com Update translation from console (flutter/flutter#171556)
2025-07-08 bkonyi@google.com [ Tool ] Support upgrading to a new Flutter version pointing to the same revision as a previous version (flutter/flutter#171783)
2025-07-08 matej.knopp@gmail.com Multi-window support (engine) (flutter/flutter#168728)
2025-07-08 34269530+PrimaelQuemerais@users.noreply.github.com Fixes an issue where TapRegion would consume taps regardless of navigation state (flutter/flutter#169067)
2025-07-08 rmolivares@renzo-olivares.dev SliverSemantics (flutter/flutter#167300)
2025-07-08 engine-flutter-autoroll@skia.org Roll Skia from e159882c6ce0 to 0fef076beec3 (3 revisions) (flutter/flutter#171779)
2025-07-08 mdebbar@google.com Run hot_restart_web_amd_test.dart on Mac/Windows (flutter/flutter#171281)
2025-07-08 engine-flutter-autoroll@skia.org Roll Packages from 2c52f24 to cba2e90 (2 revisions) (flutter/flutter#171775)

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 louisehsu@google.com,stuartmorgan@google.com 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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
ksokolovskyi pushed a commit to ksokolovskyi/flutter that referenced this pull request Aug 19, 2025
Fixes flutter#166785 

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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.

---------

Co-authored-by: Renzo Olivares <roliv@google.com>
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) d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slivers should have Sliver equivalent of the Semantics widget
2 participants