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: true,
  onChanged: (bool value) { },
  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

// TODO(framework): Add unit tests to this code snippet.
// https://github.com/flutter/flutter/issues/188530
///
/// This example resolves the [trackOutlineWidth] based on the current
/// [WidgetState] of the [Switch], providing a different outline width when it is
/// [WidgetState.disabled].
///
/// ```dart
/// Switch(
///   value: true,
///   onChanged: (bool value) { },
///   trackOutlineWidth: WidgetStateProperty.resolveWith<double?>((Set<WidgetState> states) {
///     if (states.contains(WidgetState.disabled)) {
///       return 5.0;
///     }
///     return null; // Use the default width.
///   }),
/// )
/// ```
///
/// </callout-box>
/// {@endtemplate}
///
/// Defaults to 2.0.
final WidgetStateProperty<double?>? trackOutlineWidth;