trackColor property

MaterialStateProperty<Color?>? trackColor
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 Color when it is MaterialState.disabled.
link
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 specified, overrides the default value of Switch.trackColor.

Implementation

final MaterialStateProperty<Color?>? trackColor;