sliderTheme static method

SliderThemeData sliderTheme({
  1. required ColorScheme colorScheme,
  2. SchemeColor? baseSchemeColor,
  3. SchemeColor? thumbSchemeColor,
  4. double? trackHeight,
  5. ShowValueIndicator? showValueIndicator,
  6. FlexSliderIndicatorType? valueIndicatorType,
  7. Color? valueIndicatorColor,
  8. TextStyle? valueIndicatorTextStyle,
  9. bool? useTintedInteraction,
  10. bool? useTintedDisable,
  11. bool? useOldM3Design,
  12. bool? useMaterial3,
})

An opinionated SliderThemeData theme for the Slider.

Requires a ColorScheme in colorScheme. The color scheme would typically be equal the color scheme also used to define the color scheme for your app theme.

The named parameters are:

  • colorScheme Typically the same ColorScheme that is also used for your ThemeData.

  • baseSchemeColor Selects which color from the passed in colorScheme to use as the main color for the Slider.

All colors in the color scheme are not good choices, but some work well.

If not defined, ColorScheme.primary will be used.

  • thumbSchemeColor Selects which color from the passed in colorScheme to use as the thumb color for the Slider.

If not defined, baseSchemeColor will be used.

  • trackHeight The height of the Slider track.

If not defined, defaults to 4 via Flutter SDK defaults.

  • showValueIndicator Whether the value indicator should be shown for different types of sliders.

By default, showValueIndicator is set to ShowValueIndicator.onlyForDiscrete. The value indicator is only shown when the thumb is being touched.

  • valueIndicatorType Enum used to select the type of built-in value indicator used by Slider.

The current two options included Material 2 default RectangularSliderValueIndicatorShape and Material 3 default DropSliderValueIndicatorShape.

If not defined, the default for the M2/M3 mode is used.

  • valueIndicatorColor The color given to the valueIndicatorType to draw itself with.

If undefined, defaults to using Flutter SDK's logic for the color.

  • valueIndicatorTextStyle The text style for the text on the value indicator.

If undefined, defaults to using Flutter SDK's logic for the TextStyle.

  • useTintedInteraction Defines if the theme uses tinted interaction effects.

If undefined, defaults to false.

  • useTintedDisable Defines if the theme uses tinted disabled color.

If undefined, defaults to false.

  • useOldM3Design Overrides the default value of Slider.year2023.

When true, the Slider will use the 2023 Material Design 3 appearance.

If this is set to false, the Slider will use the latest Material-3 appearance, which was introduced in December 2023 and become common in 2024.

In Flutter Material SDK, this property is named year2023.

If undefined, defaults to true, via Flutter Material's default behavior. If useMaterial3 is false, then this property is ignored.

  • useMaterial3 A temporary flag used to disable Material-3 design and use legacy Material-2 design instead. Material-3 design is the default. Material-2 will be deprecated in Flutter.

If set to true, the theme will use Material3 default styles when properties are undefined, if false defaults will use FlexColorScheme's own opinionated default values.

The M2/M3 defaults will only be used for properties that are not defined, if defined they keep their defined values.

If undefined, defaults to true.

Implementation

static SliderThemeData sliderTheme({
  /// Typically the same `ColorScheme` that is also used for your `ThemeData`.
  required final ColorScheme colorScheme,

  /// Selects which color from the passed in colorScheme to use as the main
  /// color for the Slider.
  ///
  /// All colors in the color scheme are not good choices, but some work well.
  ///
  /// If not defined, [ColorScheme.primary] will be used.
  final SchemeColor? baseSchemeColor,

  /// Selects which color from the passed in colorScheme to use as the thumb
  /// color for the Slider.
  ///
  /// If not defined, [baseSchemeColor] will be used.
  final SchemeColor? thumbSchemeColor,

  /// The height of the [Slider] track.
  ///
  /// If not defined, defaults to 4 via Flutter SDK defaults.
  final double? trackHeight,

  /// Whether the value indicator should be shown for different types of
  /// sliders.
  ///
  /// By default, [showValueIndicator] is set to
  /// [ShowValueIndicator.onlyForDiscrete]. The value indicator is only shown
  /// when the thumb is being touched.
  final ShowValueIndicator? showValueIndicator,

  /// Enum used to select the type of built-in value indicator used by
  /// [Slider].
  ///
  /// The current two options included Material 2 default
  /// [RectangularSliderValueIndicatorShape] and Material 3 default
  /// [DropSliderValueIndicatorShape].
  ///
  /// If not defined, the default for the M2/M3 mode is used.
  final FlexSliderIndicatorType? valueIndicatorType,

  /// The color given to the [valueIndicatorShape] to draw itself with.
  ///
  /// If undefined, defaults to using Flutter SDK's logic for the color.
  final Color? valueIndicatorColor,

  /// The text style for the text on the value indicator.
  ///
  /// If undefined, defaults to using Flutter SDK's logic for the TextStyle.
  final TextStyle? valueIndicatorTextStyle,

  /// Defines if the theme uses tinted interaction effects.
  ///
  /// If undefined, defaults to false.
  final bool? useTintedInteraction,

  /// Defines if the theme uses tinted disabled color.
  ///
  /// If undefined, defaults to false.
  final bool? useTintedDisable,

  /// Overrides the default value of [Slider.year2023].
  ///
  /// When true, the [Slider] will use the 2023 Material Design 3 appearance.
  ///
  /// If this is set to false, the [Slider] will use the latest Material-3
  /// appearance, which was introduced in December 2023 and become common
  /// in 2024.
  ///
  /// In Flutter Material SDK, this property is named `year2023`.
  ///
  /// If undefined, defaults to true, via Flutter Material's default behavior.
  /// If [useMaterial3] is false, then this property is ignored.
  final bool? useOldM3Design,

  /// A temporary flag used to disable Material-3 design and use legacy
  /// Material-2 design instead. Material-3 design is the default.
  /// Material-2 will be deprecated in Flutter.
  ///
  /// If set to true, the theme will use Material3 default styles when
  /// properties are undefined, if false defaults will use FlexColorScheme's
  /// own opinionated default values.
  ///
  /// The M2/M3 defaults will only be used for properties that are not
  /// defined, if defined they keep their defined values.
  ///
  /// If undefined, defaults to true.
  final bool? useMaterial3,
}) =>
    _sliderTheme(
      colorScheme: colorScheme,
      baseSchemeColor: baseSchemeColor,
      thumbSchemeColor: thumbSchemeColor,
      trackHeight: trackHeight,
      showValueIndicator: showValueIndicator,
      valueIndicatorType: valueIndicatorType,
      valueIndicatorColor: valueIndicatorColor,
      valueIndicatorTextStyle: valueIndicatorTextStyle,
      useTintedInteraction: useTintedInteraction,
      useTintedDisable: useTintedDisable,
      useOldM3Design: useOldM3Design,
      useMaterial3: useMaterial3,
    );