trackOutlineWidth property

WidgetStateProperty<double?>? trackOutlineWidth
final

The outline width of this Switch's track.

Resolved in the following states:

This example resolves the trackOutlineWidth based on the current WidgetState of the Switch, providing a different outline width 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,
  trackOutlineWidth: WidgetStateProperty.resolveWith<double?>((
    Set<WidgetState> states,
  ) {
    if (states.contains(WidgetState.disabled)) {
      return 5.0;
    }
    return null; // Use the default width.
  }),
)

Defaults to 2.0.

Implementation

final WidgetStateProperty<double?>? trackOutlineWidth;