trackColor property
final
The color of this Switch's track.
Resolved in the following states:
This example resolves the trackColor based on the current
MaterialState of the Switch, providing a different
link
Color
when it is
MaterialState.disabled.
Switch(
value: true,
onChanged: (bool value) { },
thumbColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.orange.withOpacity(.48);
}
return Colors.orange;
}),
)
If null, then the value of activeTrackColor is used in the selected state and inactiveTrackColor in the default state. If that is also null, then the value of SwitchThemeData.trackColor is used. If that is also null, then the following colors are used:
State | Light theme | Dark theme |
---|---|---|
Default | Color(0x52000000) |
Colors.white30 |
Selected | activeColor with alpha 0x80 |
activeColor with alpha 0x80 |
Disabled | Colors.black12 |
Colors.white10 |
Implementation
final MaterialStateProperty<Color?>? trackColor;