Skip to content

Default foreground color animation duration doesn't apply on icon of Button widgets #162301

@sbis04

Description

@sbis04

Steps to reproduce

  1. Create a new Flutter project
  2. Use the ElevatedButton.icon() widget and specify an icon and label widget
  3. Override the style property to the following:
    style: ButtonStyle(
      foregroundColor: WidgetStateProperty.resolveWith<Color?>(
        (states) => states.contains(WidgetState.hovered)
            ? Colors.white
            : Colors.white24,
      ),
    ),
  4. Notice the different hover animation duration on the icon and the label text (the animation doesn't seem to apply at all on the icon).

Expected results

Same default foreground color hover animation duration (kThemeChangeDuration) on both the icon and the label.

Actual results

Default foreground color animation duration doesn't apply on the icon at all, only applied on the label widget which make it look buggy (see the screen recording attached).

Code sample

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 MaterialApp(
      theme: ThemeData(useMaterial3: false),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              child: ElevatedButton.icon(
                icon: Icon(Icons.star, size: 50),
                label: Text('Button', style: TextStyle(fontSize: 36)),
                onPressed: () {},
                style: ButtonStyle(
                  foregroundColor: WidgetStateProperty.resolveWith<Color?>(
                    (states) => states.contains(WidgetState.hovered)
                        ? Colors.white
                        : Colors.white24,
                  ),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-01-28.at.10.38.23.AM.mov

Logs

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.2 24C101 darwin-arm64, locale en-IN)
    • Flutter version 3.27.3 on channel stable at /Users/souvikbiswas/fvm/versions/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision c519ee916e (6 days ago), 2025-01-21 10:32:23 -0800
    • Engine revision e672b006cb
    • Dart version 3.6.1
    • DevTools version 2.40.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/souvikbiswas/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at:
      /Users/souvikbiswas/Library/Java/JavaVirtualMachines/jbr-17.0.12/Contents/Home/bin/
      java
    • Java version OpenJDK Runtime Environment JBR-17.0.12+1-1207.37-nomod (build
      17.0.12+1-b1207.37)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16C5032a
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] VS Code (version 1.96.4)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.102.0

[✓] Connected device (6 available)
    • Pixel 9 Pro (mobile)            • 192.168.68.55:5555        • android-arm64  •
      Android 15 (API 35)
    • Souvik’s iPad Air (mobile)      • 00008101-000E41A90ED0001E • ios            • iOS
      18.1.1 22B91
    • Manisha’s iPhone (mobile)       • 00008140-000A618C0CE3001C • ios            • iOS
      18.1.1 22B91
    • macOS (desktop)                 • macos                     • darwin-arm64   •
      macOS 15.2 24C101 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         •
      macOS 15.2 24C101 darwin-arm64
    • Chrome (web)                    • chrome                    • web-javascript •
      Google Chrome 132.0.6834.111
    ! Error: Browsing on the local area network for Souvik’s Apple Watch. Ensure the
      device is unlocked and discoverable via Bluetooth. (code -27)
    ! Error: Browsing on the local area network for Souvik’s iPhone. Ensure the device is
      unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: animationAnimation APIsf: material designflutter/packages/flutter/material repository.found in release: 3.27Found to occur in 3.27found in release: 3.29Found to occur in 3.29frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

Type

No type

Projects

Status

Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions