Skip to content

Conversation

@TahaTesser
Copy link
Member

@TahaTesser TahaTesser commented Feb 4, 2025

Fixes Default foreground color animation duration doesn't apply on icon of Button widgets
Fixes Implement similar widget toAnimatedDefaultTextStyle but for child Icon

Description

This PR adds``AnimatedThemetoButtonStyleButton` 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
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),
                  },
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

Before

before.mp4

After

after.mp4

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Feb 4, 2025
@TahaTesser TahaTesser force-pushed the button_icon_animation_duration branch 8 times, most recently from 322fc87 to 29f9b78 Compare February 10, 2025 09:07
@TahaTesser TahaTesser force-pushed the button_icon_animation_duration branch from 29f9b78 to 327b200 Compare February 13, 2025 08:21
@TahaTesser TahaTesser force-pushed the button_icon_animation_duration branch from 327b200 to 575d86e Compare February 14, 2025 14:50
@TahaTesser TahaTesser marked this pull request as ready for review February 14, 2025 16:03
Copy link
Contributor

@QuncCccccc QuncCccccc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix! LGTM. Thanks! Curious whether this will cause any g3fix🫣

}

await tester.pumpWidget(buildFrame(appIconColor: Colors.lime));
await tester.pumpAndSettle();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change because of the newly added AnimatedTheme in ButtonStyleButton?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Themes requires tester.pumpAndSettle to rebuild the widget with updated theme.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my experience, when testing widget parameter and theme parameter in the same tests always requires tester.pumpAndSettle. These tests are doing the same.

@justinmc
Copy link
Contributor

Indeed this has broken Google tests.

@TahaTesser
Copy link
Member Author

TahaTesser commented Mar 4, 2025

@QuncCccccc
Could you please check broken Google tests?

@QuncCccccc
Copy link
Contributor

Ah missed this one. Yes! I'll take a look!

@QuncCccccc QuncCccccc self-requested a review March 14, 2025 22:30
@dkwingsmt
Copy link
Contributor

@QuncCccccc How's the Google testing investigation going? (from triage)

@QuncCccccc
Copy link
Contributor

Taking a look.

@QuncCccccc
Copy link
Contributor

Added g3fix: cl/747671472

@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 15, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Apr 15, 2025
Merged via the queue into flutter:master with commit a8a61a1 Apr 16, 2025
75 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Apr 16, 2025
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
@TahaTesser
Copy link
Member Author

Thank you so much for helping out! @QuncCccccc

@TahaTesser TahaTesser deleted the button_icon_animation_duration branch April 17, 2025 08:06
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
…#9098)

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
…#9098)

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
…#9098)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

4 participants