Skip to content

Semantics widget (and Icon.semanticLabel) to label custom controls for VoiceOver / TalkBack #63

Closed

Description

@AbdurahmanAlmehdi

Select your plan

Community - basic support

Confirmations

  • I searched the existing feature requests and this is not a duplicate.

Framework or plugin?

Framework

Platform

Both

Use case

Native widgets such as Text and Button(title:) get their accessibility from the platform. Custom controls don't, and there is no way to describe them: DartNative 1.0.0 has no Semantics (nor MergeSemantics / ExcludeSemantics), and Icon has no semanticLabel.

error • The function 'Semantics' isn't defined • undefined_function
error • The named parameter 'semanticLabel' isn't defined • undefined_named_parameter

Our app has two common cases:

  • A hold-to-delete button: a GestureDetector(onLongPress:) around a red circle with a trash Icon. A screen-reader user needs to hear "Hold to delete, button" and to be able to trigger it.
  • Icon-only IconButtons (export, attach, share) in toolbars and rows.

The repro puts both next to a Button(title: 'Save') and dumps the iOS accessibility tree (XCUIApplication.debugDescription from a UI test):

Other, {{16.0, 279.7}, {64.0, 64.0}}                    <- hold-to-delete (GestureDetector)
  StaticText, {{33.0, 296.7}, {30.0, 30.0}}, label: ''
Other, {{104.0, 287.7}, {48.0, 48.0}}                   <- IconButton (export)
  StaticText, {{116.0, 299.7}, {24.0, 24.0}}, label: ''
Button, {{176.0, 292.3}, {61.0, 38.3}}, label: 'Save'   <- Button(title: 'Save')

The text button is a labelled Button; the two custom controls are unlabelled glyphs with no button trait, so the tree gives VoiceOver no name for them and no sign that they can be activated.

Workaround: none that we found for the label; we put a visible text label next to some icons.

Repro repo: https://github.com/AbdurahmanAlmehdi/dartnative-repro-semantics

screenshot

The accessibility dump is in the repo at recording/a11y.txt.

Proposal

The Flutter API, mapped to the platform accessibility properties:

Semantics(
  label: 'Hold to delete',
  button: true,
  onLongPressHint: 'Delete record',
  child: GestureDetector(onLongPress: deleteRecord, child: const DeleteCircle()),
)

Icon(Icons.ios_share, semanticLabel: 'Export PDF')
  • Semantics({label, hint, value, button, header, image, selected, enabled, excludeSemantics, onTap, onLongPress, onTapHint, onLongPressHint, child}), at least label, hint, value, button, header and excludeSemantics.
  • MergeSemantics / ExcludeSemantics.
  • Icon.semanticLabel and Image.semanticLabel.

On iOS these map to isAccessibilityElement, accessibilityLabel / accessibilityHint / accessibilityValue, accessibilityTraits (.button, .header, .image, .selected) and accessibilityCustomActions; on Android to contentDescription, AccessibilityNodeInfo class name / role and AccessibilityActions (via ViewCompat / AccessibilityDelegateCompat).

Activity

  1. gabrijm commented on Oct 4, 2026

    @gabrijm
    Contributor

    Thank you for reporting this! We’ll look into it very soon and include a fix in this week’s framework update.

  2. added
    feature
    next-release
    on Oct 4, 2026
  3. gabrijm commented on Oct 6, 2026

    @gabrijm
    Contributor

    This is added and ships in this week's framework update.

    Semantics (label, value, hint, button, header, image, selected, enabled, excludeSemantics, onTap, onLongPress and their hints), MergeSemantics, ExcludeSemantics, Icon.semanticLabel and Image.semanticLabel, on VoiceOver and TalkBack:

    Semantics(
      label: 'Hold to delete',
      button: true,
      onLongPressHint: 'Delete record',
      child: GestureDetector(onLongPress: deleteRecord, child: const DeleteCircle()),
    )

    Your hold-to-delete control now reads "Hold to delete, button", and "Delete record" is in VoiceOver's actions. An IconButton reads as a button named by its tooltip or its icon's semanticLabel. If you need more than the platform's accessibility offers, you can build your own on top of these, as in Flutter.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixedfeaturenext-release

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions