sliderTheme static method
- required ColorScheme colorScheme,
- SchemeColor? baseSchemeColor,
- SchemeColor? thumbSchemeColor,
- double? trackHeight,
- ShowValueIndicator? showValueIndicator,
- FlexSliderIndicatorType? valueIndicatorType,
- Color? valueIndicatorColor,
- TextStyle? valueIndicatorTextStyle,
- bool? useTintedInteraction,
- bool? useTintedDisable,
- bool? useOldM3Design,
- 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:
-
colorSchemeTypically the sameColorSchemethat is also used for yourThemeData. -
baseSchemeColorSelects 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.
thumbSchemeColorSelects which color from the passed in colorScheme to use as the thumb color for the Slider.
If not defined, baseSchemeColor will be used.
trackHeightThe height of the Slider track.
If not defined, defaults to 4 via Flutter SDK defaults.
showValueIndicatorWhether 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.
valueIndicatorTypeEnum 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.
valueIndicatorColorThe color given to thevalueIndicatorTypeto draw itself with.
If undefined, defaults to using Flutter SDK's logic for the color.
valueIndicatorTextStyleThe text style for the text on the value indicator.
If undefined, defaults to using Flutter SDK's logic for the TextStyle.
useTintedInteractionDefines if the theme uses tinted interaction effects.
If undefined, defaults to false.
useTintedDisableDefines if the theme uses tinted disabled color.
If undefined, defaults to false.
useOldM3DesignOverrides the default value ofSlider.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.
useMaterial3A 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,
);