Skip to content

IconButton.color is overidden by IconButtonTheme #174511

@bleroux

Description

@bleroux

Steps to reproduce

  1. Run the code sample
  2. Observe the icon button color

Expected results

The icon is green according to IconButton.color property

Image

Actual results

The icon is purple according to the ambient IconButtonTheme, despite IconButton.color being set to green.

Image

Code sample

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

void main() => runApp(const IconButtonDemo());

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        iconButtonTheme: const IconButtonThemeData(
          style: ButtonStyle(iconColor: WidgetStateColor.fromMap({WidgetState.any: Colors.purple})),
        ),
      ),
      home: Scaffold(
        body: Center(
          child: IconButton(
            onPressed: () {},
            icon: const Icon(Icons.build_circle, size: 64),
            color: Colors.green,
          ),
        ),
      ),
    );
  }
}

Screenshots or Video

Logs

Flutter Doctor output

Doctor output
Flutter (Channel [user-branch], 3.36.0-1.0.pre-286, on Ubuntu 24.04.2 LTS 6.8.0-78-generic, locale fr_FR.UTF-8)

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listf: material designflutter/packages/flutter/material repository.found in release: 3.35Found to occur in 3.35found in release: 3.36Found to occur in 3.36frameworkflutter/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