Repository navigation
Closed
flutter/packages
#13084Closed
Copy link
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Description
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:
- Even inside Flutter's own Material library (
icon_button.dart),_IconButtonM3 extends ButtonStyleButtonhas to be wrapped in a separate 100-line_SelectableIconButton extends StatefulWidgetsolely to allocate aWidgetStatesController, synchronizeWidgetState.selectedininitState/didUpdateWidget, and wrap the child inSemantics(selected: isSelected). - Every custom
ButtonStyleButtonsubclass or toggleable Material button must duplicate that boilerplateStatefulWidgetwrapper to manageWidgetStatesControllerlifecycle andSemantics(selected: ...).
Proposal
Add an optional bool? isSelected property directly to ButtonStyleButton:
- In
_ButtonStyleState.initStatesController(), ifwidget.isSelected != null, callstatesController.update(WidgetState.selected, widget.isSelected!). - In
_ButtonStyleState.didUpdateWidget(), ifwidget.isSelected != oldWidget.isSelected, callstatesController.update(WidgetState.selected, widget.isSelected ?? false). - In
_ButtonStyleState.build(), passselected: widget.isSelectedto the outerSemanticswidget. - Optionally simplify
_IconButtonM3inicon_button.dartby passingisSelecteddirectly toButtonStyleButtonand removing_SelectableIconButton.
Reacted by Mairramer
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-designOwned by Design Languages teamOwned by Design Languages teamtriaged-designTriaged by Design Languages teamTriaged by Design Languages team
Activity
suryaKommana2662 commentedon Oct 12, 2026
@sasikumar Thanks for the detailed proposal. I'm routing this issue to the
team-designfor further consideration.QuncCccccc commentedon Oct 15, 2026
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 addisSelectedinButtonStyleButton.[material_ui] Add Material 3 Expressive `ElevatedButton` (flutter#13084)