Bruno Leroux 46b6f40982
Fix ElevatedButton.icon breaks focus traversal and VoiceOver when toggling icon (#177579)
## Description

This PR changes `ElevatedButton.icon` to avoid building a different
widget. When a different widget is created the whole subtree is
recreated which leads to various issues (Focus and A11y issues for
instance).
The change is similar to https://github.com/flutter/flutter/pull/175810
which fixed the exact same problem for `OutlinedButton.icon`.

## Related Issue

[TextButton.icon breaks focus traversal and ink effect when toggling
icon](https://github.com/flutter/flutter/issues/173944)
[Voiceover focus traversal breaks if a button's state changes to include
an icon](https://github.com/flutter/flutter/pull/175810)

## Tests

- Adds 2 tests
2025-10-31 15:01:19 +00:00
..
2025-07-28 15:07:11 +00:00

Flutter gallery

An older copy of the Flutter gallery demo application used for integration testing.

For the current Flutter Gallery app sample, see this repo: https://github.com/flutter/gallery

Icon

Android launcher icons were generated using Android Asset Studio: https://romannurik.github.io/AndroidAssetStudio/icons-launcher.html#foreground.type=image&foreground.space.trim=1&foreground.space.pad=0.1&foreColor=607d8b%2C0&crop=0&backgroundShape=square&backColor=fafafa%2C100&effects=none

Video demo

The video demo is not supported on iOS simulators.