fillColor property
The color that fills the radio button, in all WidgetStates.
Resolves in the following states:
This example resolves the fillColor based on the current WidgetState of the Radio, providing a different Color when it is WidgetState.disabled.
Radio<int>(
value: 1,
fillColor: WidgetStateProperty.resolveWith<Color>((Set<WidgetState> states) {
if (states.contains(WidgetState.disabled)) {
return Colors.orange.withValues(alpha: .32);
}
return Colors.orange;
})
)
If null, then the value of activeColor is used in the selected state. If that is also null, then the value of RadioThemeData.fillColor is used. If that is also null and ThemeData.useMaterial3 is false, then ThemeData.disabledColor is used in the disabled state, ColorScheme.secondary is used in the selected state, and ThemeData.unselectedWidgetColor is used in the default state; if ThemeData.useMaterial3 is true, then ColorScheme.onSurface is used in the disabled state, ColorScheme.primary is used in the selected state and ColorScheme.onSurfaceVariant is used in the default state.
Implementation
// TODO(framework): Add unit tests to this code snippet.
// https://github.com/flutter/flutter/issues/188530
///
/// This example resolves the [fillColor] based on the current [WidgetState]
/// of the [Radio], providing a different [Color] when it is
/// [WidgetState.disabled].
///
/// ```dart
/// Radio<int>(
/// value: 1,
/// fillColor: WidgetStateProperty.resolveWith<Color>((Set<WidgetState> states) {
/// if (states.contains(WidgetState.disabled)) {
/// return Colors.orange.withValues(alpha: .32);
/// }
/// return Colors.orange;
/// })
/// )
/// ```
///
/// </callout-box>
/// {@endtemplate}
///
/// If null, then the value of [activeColor] is used in the selected state. If
/// that is also null, then the value of [RadioThemeData.fillColor] is used.
/// If that is also null and [ThemeData.useMaterial3] is false, then
/// [ThemeData.disabledColor] is used in the disabled state, [ColorScheme.secondary]
/// is used in the selected state, and [ThemeData.unselectedWidgetColor] is used in the
/// default state; if [ThemeData.useMaterial3] is true, then [ColorScheme.onSurface]
/// is used in the disabled state, [ColorScheme.primary] is used in the
/// selected state and [ColorScheme.onSurfaceVariant] is used in the default state.
final WidgetStateProperty<Color?>? fillColor;