Skip to content

Add backgroundColor to RadioThemeData - #171326

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
ValentinVignal:flutter/Add-background-color-to-radio-theme-data
Jul 2, 2025
Merged

Add backgroundColor to RadioThemeData#171326
auto-submit[bot] merged 3 commits into
flutter:masterfrom
ValentinVignal:flutter/Add-background-color-to-radio-theme-data

Conversation

@ValentinVignal

Copy link
Copy Markdown
Contributor

Part of #168787

Follow-up of #171204

Pre-launch Checklist

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

@github-actionsgithub-actionsBot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages labels Jun 28, 2025
Comment on lines +664 to +670
widget.backgroundColor?.resolve(activeStates) ??
radioTheme.backgroundColor?.resolve(activeStates) ??
Colors.transparent;
final Color inactiveBackgroundColor =
widget.backgroundColor?.resolve(inactiveStates) ?? Colors.transparent;
widget.backgroundColor?.resolve(inactiveStates) ??
radioTheme.backgroundColor?.resolve(inactiveStates) ??
Colors.transparent;

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

I want to bring back the question from #169415 (comment)

I'm not sure how we want to handle those transparent colors? The other properties are using _RadioDefaultsM3 or _RadioDefaultsM2 as a fallbacks.

What is the best thing to do here?

Is this something that could/should be in the Material token database? Or is this ok as-is?

cc @chunhtai@justinmc@QuncCccccc

@QuncCcccccQuncCcccccJun 30, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry I missed the conversation over there! Yes, we should add the transparent backgroundColor in the 2 default RadioThemeData. I don't think there's any tokens that specify the background color, so no token will need to be involved.

To add the default value in _RadioDefaultsM2:
we can just go to the class and add it manually.

For _RadioDefaultsM3:
We should go to dev/tools/gen_defaults/lib/radio_template.dart, add the default value for backgroundColor, then run script dev/tools/gen_defaults/bin/gen_defaults.dart in the root. The script will generate default M3 theme Data for us.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Awesome thank you! I added it in Add background Color to defaults

@QuncCcccccQuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thank you for your contribution:)!

@chunhtaichunhtai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@dkwingsmtdkwingsmt added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 2, 2025
@auto-submit
auto-submitBot added this pull request to the merge queueJul 2, 2025
Merged via the queue into flutter:master with commit bf3e856Jul 2, 2025
@flutter-dashboardflutter-dashboardBot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 2, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 3, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 4, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Jul 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frameworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@ValentinVignal@QuncCccccc@chunhtai@dkwingsmt