Skip to content

Slivers should have Sliver equivalent of the Semantics widget #166785

@Renzo-Olivares

Description

@Renzo-Olivares

Use case

Currently there is no way to annotate semantic properties onto Slivers other than building your own RenderProxySliver that overrides describeSemanticsConfiguration, example below.

// A sliver that assigns the role of SemanticsRole.list to its sliver child.
class SliverSemanticsList extends SingleChildRenderObjectWidget {
  const SliverSemanticsList({super.key, required Widget sliver})
    : super(child: sliver);

  @override
  RenderSliverSemanticsList createRenderObject(BuildContext context) =>
      RenderSliverSemanticsList();
}

class RenderSliverSemanticsList extends RenderProxySliver {
  @override
  void describeSemanticsConfiguration(SemanticsConfiguration config) {
    super.describeSemanticsConfiguration(config);
    config.role = SemanticsRole.list;
  }
}

Proposal

There should be a Sliver equivalent of the Semantics widget, SliverSemantics, to enable use-cases such as marking a SliverList with a SemanicsRole.list.

SliverSemantics(
  role: SemanticsRole.list
  sliver: SliverFixedExtentList(
    itemExtent: 44.0,
    delegate: SliverChildBuilderDelegate(
      (BuildContext context, int index) {
        return Card(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Text('Item $index'),
          ),
        );
      },
      childCount: 50,
    ),
  ),
),

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions