trackOutlineColor property
The outline color of this Switch's track.
Resolved in the following states:
This example resolves the trackOutlineColor based on the current
WidgetState of the Switch, providing a different Color when it is
WidgetState.disabled.
Switch(
value: _value,
// If `onChanged` is null, this switch is disabled.
// If `onChanged` is not null, this switch is enabled.
onChanged: _nullableOnChanged,
trackOutlineColor: WidgetStateProperty.resolveWith<Color?>((
Set<WidgetState> states,
) {
if (states.contains(WidgetState.disabled)) {
return Colors.orange.withValues(alpha: .48);
}
return null; // Use the default color.
}),
)
If specified, overrides the default value of Switch.trackOutlineColor.
Implementation
final WidgetStateProperty<Color?>? trackOutlineColor;