-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Unable to change Radio() widget fillColor with ThemeData.radioTheme #159269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report and root-cause with potential solution. Keeping the issue open and labeling for team's tracking. |
Hey!
@darshankawar Could you please let me know if there was any internal discussion in the team about this? |
@wzslr321 Feel free to work on this (I will assign you, this way others know you are working on this issue). Little advise to look carefully at similar code, especially for the tests. |
Hey @kosiara I am unable to reproduce the issue. Codeimport 'package:flutter/material.dart';
enum Foo { Bar, Baz }
void main() {
return runApp(const MaterialApp(home: App()));
}
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
class _AppState extends State<App> {
Foo? _groupValue = Foo.Bar;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Theme(
data: ThemeData(
radioTheme: RadioThemeData(
fillColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.blueAccent.withOpacity(.32);
}
return Colors.blueAccent;
}),
),
),
child: Radio<Foo>(
value: Foo.Bar,
groupValue: _groupValue,
onChanged: (Foo? value) {
setState(() {
_groupValue = value;
});
},
),
),
Radio<Foo>(
value: Foo.Baz,
groupValue: _groupValue,
onChanged: (Foo? value) {
setState(() {
_groupValue = value;
});
},
),
],
),
),
);
}
} It was acting as expected - one radio had a flutter doctorDoctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.0, on macOS 15.1 24B83 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.3)
[✓] VS Code (version 1.96.2)
[✓] Connected device (5 available)
[✓] Network resources
• No issues found! Could you @kosiara please help me understand if my reproduce attempt was correct? If so, could you provide me with more details about platform on which the issue occurs, as maybe it is platform specific? |
I can confirm that this is working as expected! |
@darshankawar Would you mind checking this against current master? I think @wzslr321 and @AnujLM are right. It's fixed now. |
This issue is assigned to @wzslr321 but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks! |
Hi @kosiara, I also tried reproducing the issue but was unable to do so. It seems to be working fine on flutter version ![]()
|
@Piinks sounds like we can close this issue |
Thanks! |
Steps to reproduce
One cannot define a Theme for a Radio button widget which changes the
fillColor
:I believe it's because of the way Radio() widget is defined in
./packages/flutter/lib/src/material/radio.dart
especially:
line: 485
where
_widgetFillColor
is always defined to be:a hotfix for that would be to define it directly in the Radio widget:
Expected results
Expected result would be to respect context.theme.themeData.radioTheme.fillColor data in Radio() widget
Actual results
Radio() widget ignores context.theme.themeData.radioTheme.fillColor and is always the default color unless one overrides fillColor directly in the Widget
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: