Taha Tesser
a8a61a1c06
Add button icon support for animation duration (#162667)
Fixes [Default foreground color animation duration doesn't apply on icon
of `Button` widgets](https://github.com/flutter/flutter/issues/162301)
Fixes [Implement similar widget to``AnimatedDefaultTextStyle`` but for
child ``Icon``](https://github.com/flutter/flutter/issues/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 <36861262+QuncCccccc@users.noreply.github.com>
2025-04-15 23:52:25 +00:00
..
2025-03-14 17:50:20 +00:00
2025-01-22 21:52:11 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-04-15 23:52:25 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-01-24 21:33:27 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-04-02 21:28:56 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 21:28:56 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-05 21:27:21 +00:00
2025-04-02 21:28:56 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-01-14 05:13:41 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 22:00:19 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 22:00:19 +00:00
2025-04-11 19:38:16 +00:00
2025-04-02 21:28:56 +00:00
2025-02-06 18:40:25 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-19 05:40:18 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-24 07:07:51 +00:00
2025-04-09 19:43:19 +00:00
2024-12-19 20:06:21 +00:00
2025-03-19 20:33:15 +00:00
2025-04-15 23:52:25 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 21:28:56 +00:00
2025-01-22 21:52:11 +00:00
2025-04-15 23:52:25 +00:00
2025-02-13 08:33:12 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-04-15 23:52:25 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-01-24 21:33:27 +00:00
2025-03-14 17:50:20 +00:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2025-01-22 21:52:11 +00:00
2025-04-02 22:00:19 +00:00
2025-04-15 23:52:25 +00:00
2025-04-09 04:47:20 +00:00
2025-04-09 04:47:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-02-03 23:55:03 +00:00
2024-12-19 20:06:21 +00:00
2023-02-15 17:41:41 -08:00
2025-01-24 21:33:27 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-02 21:28:56 +00:00
2025-03-14 17:50:20 +00:00
2025-04-02 21:28:56 +00:00
2025-03-13 08:02:36 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-04-15 23:52:25 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-04-02 21:27:07 +00:00
2025-03-17 17:00:05 +00:00
2024-12-19 20:06:21 +00:00
2025-04-03 00:33:58 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-02-20 07:48:23 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-04-10 18:30:06 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-04-02 21:28:56 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-04-04 21:15:12 +00:00
2025-03-14 17:50:20 +00:00
2025-03-18 21:01:16 +00:00
2025-03-14 17:50:20 +00:00
2025-04-15 23:52:25 +00:00
2025-03-14 17:50:20 +00:00
2025-02-28 02:30:37 +00:00
2025-03-14 17:50:20 +00:00
2025-04-10 18:30:06 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-01-15 11:23:41 +00:00
2025-04-15 23:52:25 +00:00
2025-03-14 17:50:20 +00:00
2025-01-14 05:13:41 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-24 16:53:04 +00:00
2025-04-10 07:11:24 +00:00
2025-03-24 16:53:04 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-03-14 17:50:20 +00:00
2025-02-21 18:40:05 +00:00
2025-03-26 19:25:07 +00:00
2025-03-14 17:50:20 +00:00
2025-03-31 18:46:44 +00:00
2025-04-15 18:37:50 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2025-04-15 23:52:25 +00:00
2025-04-15 23:52:25 +00:00
2025-03-17 17:00:05 +00:00
2025-03-17 17:00:05 +00:00
2024-12-19 20:06:21 +00:00
2025-03-14 17:50:20 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00
2024-12-19 20:06:21 +00:00