trackOutlineColor property

MaterialStateProperty<Color?>? trackOutlineColor
final

The outline color of this Switch's track.

Resolved in the following states:

This example resolves the trackOutlineColor based on the current MaterialState of the Switch, providing a different Color when it is MaterialState.disabled.
link
Switch(
  value: true,
  onChanged: (bool value) { },
  trackOutlineColor: MaterialStateProperty.resolveWith<Color?>((Set<MaterialState> states) {
    if (states.contains(MaterialState.disabled)) {
      return Colors.orange.withOpacity(.48);
    }
    return null; // Use the default color.
  }),
)

In Material 3, the outline color defaults to transparent in the selected state and ColorScheme.outline in the unselected state. In Material 2, the Switch track has no outline by default.

Implementation

final MaterialStateProperty<Color?>? trackOutlineColor;