Skip to content

Button Widgets (.icon Constructor) ignores foregroundColor from .styleFrom #161467

@kishan-dhankecha

Description

@kishan-dhankecha

Steps to reproduce

  1. flutter create bug.
  2. Replace the given code below with the contents of main.dart.
  3. Run the project.

Expected results

The icon color should be what is provided in the foregroundColor property.

Actual results

It is taking default color instead of the provided foregroundColor. Note that text color is working as expected. Issue is only with icons.

I tested this so far on:

3.24.5 3.27.1 3.28.0-2.0.pre.38697

✅ correct behavior
❌ wrong behavior

Code sample

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MainApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              ElevatedButton.icon(
                onPressed: () {},
                icon: const Icon(Icons.add),
                label: const Text('Add'),
                style: ElevatedButton.styleFrom(
                  foregroundColor: Colors.white,
                  backgroundColor: Colors.green,
                ),
              ),
              OutlinedButton.icon(
                onPressed: () {},
                icon: const Icon(Icons.remove),
                label: const Text('Remove'),
                style: OutlinedButton.styleFrom(
                  foregroundColor: Colors.red,
                  backgroundColor: Colors.white,
                ),
              ),
              FilledButton.icon(
                onPressed: () {},
                icon: const Icon(Icons.edit),
                label: const Text('Edit'),
                style: FilledButton.styleFrom(
                  foregroundColor: Colors.white,
                  backgroundColor: Colors.blue,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration
Expected Actual
Screenshot_1736579138 Screenshot_1736579216

Logs

Logs
Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
Running Gradle task 'assembleDebug'...                           2,743ms
✓ Built build/app/outputs/flutter-apk/app-debug.apk
Syncing files to device sdk gphone64 arm64...                       61ms

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

A Dart VM Service on sdk gphone64 arm64 is available at: http://127.0.0.1:59216/UgEzclwXAiM=/
The Flutter DevTools debugger and profiler on sdk gphone64 arm64 is available at:
http://127.0.0.1:9104?uri=http://127.0.0.1:59216/UgEzclwXAiM=/

Application finished.

Flutter Doctor output

Last Stable Chanel (3.24.5) ✅
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel [user-branch], 3.24.5, on macOS 15.2 24C101 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.96.2)
[✓] Connected device (4 available)
[✓] Network resources

! Doctor found issues in 1 category.
Current Stable Chanel (3.27.1) ❌
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.1, on macOS 15.2 24C101 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.96.2)
[✓] Connected device (4 available)
[✓] Network resources

• No issues found!
Current Master Chanel (3.28.0-2.0.pre.38697) ❌
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel master, 3.28.0-2.0.pre.38697, on macOS 15.2 24C101 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2024.2)
[✓] VS Code (version 1.96.2)
[✓] Connected device (4 available)
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    r: invalidIssue is closed as not valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions