Skip to content

Add optional isSelected toggle state support to ButtonStyleButton #194202

Closed
flutter/packages
#13084

Description

@sasikumar

Use case

In Material 3 and Material 3 Expressive (see #168813, #184936, #184937), common buttons (FilledButton, FilledButton.tonal, ElevatedButton, OutlinedButton, TextButton) and custom ButtonStyleButton subclasses support toggleable selected/unselected states (updating WidgetState.selected for color/shape resolution and setting Semantics.selected for accessibility).

Currently, ButtonStyleButton does not expose an isSelected parameter. As a result:

  1. Even inside Flutter's own Material library (icon_button.dart), _IconButtonM3 extends ButtonStyleButton has to be wrapped in a separate 100-line _SelectableIconButton extends StatefulWidget solely to allocate a WidgetStatesController, synchronize WidgetState.selected in initState/didUpdateWidget, and wrap the child in Semantics(selected: isSelected).
  2. Every custom ButtonStyleButton subclass or toggleable Material button must duplicate that boilerplate StatefulWidget wrapper to manage WidgetStatesController lifecycle and Semantics(selected: ...).

Proposal

Add an optional bool? isSelected property directly to ButtonStyleButton:

  • In _ButtonStyleState.initStatesController(), if widget.isSelected != null, call statesController.update(WidgetState.selected, widget.isSelected!).
  • In _ButtonStyleState.didUpdateWidget(), if widget.isSelected != oldWidget.isSelected, call statesController.update(WidgetState.selected, widget.isSelected ?? false).
  • In _ButtonStyleState.build(), pass selected: widget.isSelected to the outer Semantics widget.
  • Optionally simplify _IconButtonM3 in icon_button.dart by passing isSelected directly to ButtonStyleButton and removing _SelectableIconButton.

Activity

  1. suryaKommana2662 commented on Oct 12, 2026

    @suryaKommana2662
    Contributor

    @sasikumar Thanks for the detailed proposal. I'm routing this issue to the team-design for further consideration.

  2. added
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    team-designOwned by Design Languages team
    and removed
    in triagePresently being triaged by the triage team
    on Oct 12, 2026
  3. QuncCccccc commented on Oct 15, 2026

    @QuncCccccc
    Contributor

    Thanks for filing this issue:)! Just to clarify, toggle functionality is a new feature in Material 3 Expressive, not Material 3 baseline. M3E migration is still ongoing and I'm actively working on adding M3E support for ElevatedButton; it will add isSelected in ButtonStyleButton.

  4. added
    P2Important issues not at the top of the work list
    triaged-designTriaged by Design Languages team
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    team-designOwned by Design Languages team
    and removed
    p: material_uimaterial_ui package in flutter/packages
    packageflutter/packages repository. See also p: labels.
    c: proposalA detailed proposal for a change to Flutter
    P2Important issues not at the top of the work list
    team-designOwned by Design Languages team
    on Oct 15, 2026
  5. self-assigned this
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.team-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions