Add button icon support for animation duration#162667
Merged
auto-submit[bot] merged 3 commits intoflutter:masterfrom Apr 16, 2025
TahaTesser:button_icon_animation_duration
Merged
Add button icon support for animation duration#162667auto-submit[bot] merged 3 commits intoflutter:masterfrom TahaTesser:button_icon_animation_duration
auto-submit[bot] merged 3 commits intoflutter:masterfrom
TahaTesser:button_icon_animation_duration
Conversation
This was referenced Feb 4, 2025
QuncCccccc
approved these changes
Feb 25, 2025
| } | ||
|
|
||
| await tester.pumpWidget(buildFrame(appIconColor: Colors.lime)); | ||
| await tester.pumpAndSettle(); |
Contributor
There was a problem hiding this comment.
Is this change because of the newly added AnimatedTheme in ButtonStyleButton?
Contributor
Author
There was a problem hiding this comment.
Yes, Themes requires tester.pumpAndSettle to rebuild the widget with updated theme.
Contributor
Author
There was a problem hiding this comment.
In my experience, when testing widget parameter and theme parameter in the same tests always requires tester.pumpAndSettle. These tests are doing the same.
Contributor
|
Indeed this has broken Google tests. |
Contributor
Author
|
@QuncCccccc |
Contributor
|
Ah missed this one. Yes! I'll take a look! |
Contributor
|
@QuncCccccc How's the Google testing investigation going? (from triage) |
Contributor
|
Taking a look. |
Contributor
|
Added g3fix: cl/747671472 |
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 16, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Apr 16, 2025
mboetger
pushed a commit
to mboetger/flutter
that referenced
this pull request
Apr 16, 2025
Fixes [Default foreground color animation duration doesn't apply on icon of `Button` widgets](flutter#162301) Fixes [Implement similar widget to``AnimatedDefaultTextStyle`` but for child ``Icon``](flutter#137251) ### Description This PR adds``AnimatedTheme` to `ButtonStyleButton` which is extended by buttons. It animates the button icon when changing icon color and size, similar to button text. ### Code Sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @OverRide Widget build(BuildContext context) { return const MaterialApp( home: HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({super.key}); @OverRide Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, spacing: 20, children: <Widget>[ ElevatedButton.icon( icon: const Icon(Icons.favorite_rounded, size: 50), label: const Text('Button', style: TextStyle(fontSize: 36)), onPressed: () {}, style: const ButtonStyle( iconColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), foregroundColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), ), ), ElevatedButton.icon( icon: const Icon(Icons.favorite_rounded, size: 50), label: const Text('Button', style: TextStyle(fontSize: 36)), onPressed: () {}, style: const ButtonStyle( animationDuration: Duration(seconds: 2), iconColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), foregroundColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), ), ) ], ), ), ); } } ``` </details> ### Before https://github.com/user-attachments/assets/86fcab94-1147-4c49-b362-12f804a5d540 ### After https://github.com/user-attachments/assets/12a49de8-06d6-46c5-976f-5ce182d60423 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md Co-authored-by: Qun Cheng <[email protected]>
auto-submit bot
pushed a commit
to flutter/packages
that referenced
this pull request
Apr 16, 2025
flutter/flutter@db68c95...aef4718 2025-04-16 [email protected] [Web] Remove `webOnlyUniformRadii` from `RRect` (flutter/flutter#167237) 2025-04-16 [email protected] Roll Skia from 76cb5d4fba27 to 6627deb65939 (10 revisions) (flutter/flutter#167249) 2025-04-16 [email protected] Adding macrobenchmarks for DDC (flutter/flutter#166617) 2025-04-15 [email protected] Add button icon support for animation duration (flutter/flutter#162667) 2025-04-15 [email protected] Roll Dartdoc to 8.3.3 (flutter/flutter#167231) 2025-04-15 [email protected] Removed superfluous copy in license checker (flutter/flutter#167146) 2025-04-15 [email protected] license checker: ignore git sha in dart license (flutter/flutter#167153) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Contributor
Author
|
Thank you so much for helping out! @QuncCccccc |
ash2moon
pushed a commit
to ash2moon/flutter
that referenced
this pull request
Apr 21, 2025
Fixes [Default foreground color animation duration doesn't apply on icon of `Button` widgets](flutter#162301) Fixes [Implement similar widget to``AnimatedDefaultTextStyle`` but for child ``Icon``](flutter#137251) ### Description This PR adds``AnimatedTheme` to `ButtonStyleButton` which is extended by buttons. It animates the button icon when changing icon color and size, similar to button text. ### Code Sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @OverRide Widget build(BuildContext context) { return const MaterialApp( home: HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({super.key}); @OverRide Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, spacing: 20, children: <Widget>[ ElevatedButton.icon( icon: const Icon(Icons.favorite_rounded, size: 50), label: const Text('Button', style: TextStyle(fontSize: 36)), onPressed: () {}, style: const ButtonStyle( iconColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), foregroundColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), ), ), ElevatedButton.icon( icon: const Icon(Icons.favorite_rounded, size: 50), label: const Text('Button', style: TextStyle(fontSize: 36)), onPressed: () {}, style: const ButtonStyle( animationDuration: Duration(seconds: 2), iconColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), foregroundColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), ), ) ], ), ), ); } } ``` </details> ### Before https://github.com/user-attachments/assets/86fcab94-1147-4c49-b362-12f804a5d540 ### After https://github.com/user-attachments/assets/12a49de8-06d6-46c5-976f-5ce182d60423 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md Co-authored-by: Qun Cheng <[email protected]>
CodixNinja
pushed a commit
to CodixNinja/packages
that referenced
this pull request
May 15, 2025
flutter/flutter@db68c95...aef4718 2025-04-16 [email protected] [Web] Remove `webOnlyUniformRadii` from `RRect` (flutter/flutter#167237) 2025-04-16 [email protected] Roll Skia from 76cb5d4fba27 to 6627deb65939 (10 revisions) (flutter/flutter#167249) 2025-04-16 [email protected] Adding macrobenchmarks for DDC (flutter/flutter#166617) 2025-04-15 [email protected] Add button icon support for animation duration (flutter/flutter#162667) 2025-04-15 [email protected] Roll Dartdoc to 8.3.3 (flutter/flutter#167231) 2025-04-15 [email protected] Removed superfluous copy in license checker (flutter/flutter#167146) 2025-04-15 [email protected] license checker: ignore git sha in dart license (flutter/flutter#167153) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
androidseb
pushed a commit
to androidseb/packages
that referenced
this pull request
Jun 8, 2025
flutter/flutter@db68c95...aef4718 2025-04-16 [email protected] [Web] Remove `webOnlyUniformRadii` from `RRect` (flutter/flutter#167237) 2025-04-16 [email protected] Roll Skia from 76cb5d4fba27 to 6627deb65939 (10 revisions) (flutter/flutter#167249) 2025-04-16 [email protected] Adding macrobenchmarks for DDC (flutter/flutter#166617) 2025-04-15 [email protected] Add button icon support for animation duration (flutter/flutter#162667) 2025-04-15 [email protected] Roll Dartdoc to 8.3.3 (flutter/flutter#167231) 2025-04-15 [email protected] Removed superfluous copy in license checker (flutter/flutter#167146) 2025-04-15 [email protected] license checker: ignore git sha in dart license (flutter/flutter#167153) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
FMorschel
pushed a commit
to FMorschel/packages
that referenced
this pull request
Jun 9, 2025
flutter/flutter@db68c95...aef4718 2025-04-16 [email protected] [Web] Remove `webOnlyUniformRadii` from `RRect` (flutter/flutter#167237) 2025-04-16 [email protected] Roll Skia from 76cb5d4fba27 to 6627deb65939 (10 revisions) (flutter/flutter#167249) 2025-04-16 [email protected] Adding macrobenchmarks for DDC (flutter/flutter#166617) 2025-04-15 [email protected] Add button icon support for animation duration (flutter/flutter#162667) 2025-04-15 [email protected] Roll Dartdoc to 8.3.3 (flutter/flutter#167231) 2025-04-15 [email protected] Removed superfluous copy in license checker (flutter/flutter#167146) 2025-04-15 [email protected] license checker: ignore git sha in dart license (flutter/flutter#167153) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Ortes
pushed a commit
to Ortes/packages
that referenced
this pull request
Jun 25, 2025
flutter/flutter@db68c95...aef4718 2025-04-16 [email protected] [Web] Remove `webOnlyUniformRadii` from `RRect` (flutter/flutter#167237) 2025-04-16 [email protected] Roll Skia from 76cb5d4fba27 to 6627deb65939 (10 revisions) (flutter/flutter#167249) 2025-04-16 [email protected] Adding macrobenchmarks for DDC (flutter/flutter#166617) 2025-04-15 [email protected] Add button icon support for animation duration (flutter/flutter#162667) 2025-04-15 [email protected] Roll Dartdoc to 8.3.3 (flutter/flutter#167231) 2025-04-15 [email protected] Removed superfluous copy in license checker (flutter/flutter#167146) 2025-04-15 [email protected] license checker: ignore git sha in dart license (flutter/flutter#167153) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 14, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 14, 2025
romanejaquez
pushed a commit
to romanejaquez/flutter
that referenced
this pull request
Aug 14, 2025
Fixes [Default foreground color animation duration doesn't apply on icon of `Button` widgets](flutter#162301) Fixes [Implement similar widget to``AnimatedDefaultTextStyle`` but for child ``Icon``](flutter#137251) ### Description This PR adds``AnimatedTheme` to `ButtonStyleButton` which is extended by buttons. It animates the button icon when changing icon color and size, similar to button text. ### Code Sample <details> <summary>expand to view the code sample</summary> ```dart import 'package:flutter/material.dart'; void main() => runApp(const MyApp()); class MyApp extends StatelessWidget { const MyApp({super.key}); @OverRide Widget build(BuildContext context) { return const MaterialApp( home: HomePage(), ); } } class HomePage extends StatelessWidget { const HomePage({super.key}); @OverRide Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, spacing: 20, children: <Widget>[ ElevatedButton.icon( icon: const Icon(Icons.favorite_rounded, size: 50), label: const Text('Button', style: TextStyle(fontSize: 36)), onPressed: () {}, style: const ButtonStyle( iconColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), foregroundColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), ), ), ElevatedButton.icon( icon: const Icon(Icons.favorite_rounded, size: 50), label: const Text('Button', style: TextStyle(fontSize: 36)), onPressed: () {}, style: const ButtonStyle( animationDuration: Duration(seconds: 2), iconColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), foregroundColor: WidgetStateProperty<Color>.fromMap( <WidgetStatesConstraint, Color>{ WidgetState.pressed: Color(0XFFFF0000), WidgetState.any: Color(0XFF000000), }, ), ), ) ], ), ), ); } } ``` </details> ### Before https://github.com/user-attachments/assets/86fcab94-1147-4c49-b362-12f804a5d540 ### After https://github.com/user-attachments/assets/12a49de8-06d6-46c5-976f-5ce182d60423 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md Co-authored-by: Qun Cheng <[email protected]>
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 15, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 15, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Aug 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes Default foreground color animation duration doesn't apply on icon of
ButtonwidgetsFixes Implement similar widget to
AnimatedDefaultTextStylebut for childIconDescription
This PR adds``AnimatedTheme
toButtonStyleButton` which is extended by buttons. It animates the button icon when changing icon color and size, similar to button text.Code Sample
expand to view the code sample
Before
before.mp4
After
after.mp4
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.