flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.2k stars 27.49k forks source link

Don't overwrite the icon theme in CupertinoButton #149172

Closed ricardoboss closed 4 months ago

ricardoboss commented 5 months ago

Use case

I have a widget that shows a row of buttons and I want to apply an IconTheme to them for setting their size.

Currently, I have to set the size for each icon within each button individually, because the CupertinoButton widget overwrites any IconTheme provided above it in the tree.

Proposal

I'd like to propose that the build method in _CupertinoButtonState uses IconTheme.of(context).copyWith(color: foregroundColor) to set the theme instead of just IconTheme(color: foregroundColor).

This way, it sets the correct color but also incorporates any parent styles.

ricardoboss commented 5 months ago

@darshankawar @Piinks Is the proposal alright with you? Can I try taking a stab at implementing this?

darshankawar commented 5 months ago

@ricardoboss Feel free to raise a PR. The team can give feedback if any while reviewing it.

github-actions[bot] commented 4 months ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.