Skip to content

Commit a1ed23c

Browse files
authored
[material_ui] Clarify Slider labels for continuous sliders (#13121)
Clarifies that `Slider.label` can be displayed for continuous sliders when the value indicator configuration allows it. Documents the discrete-slider default, widget-level settings for continuous sliders, and the fallback to `SliderThemeData.showValueIndicator`. Fixes #74098. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent d7ebbe2 commit a1ed23c

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎packages/material_ui/lib/src/slider.dart‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,16 @@ class Slider extends StatefulWidget {
430430
/// If null, the slider is continuous.
431431
final int? divisions;
432432

433-
/// A label to show above the slider when the slider is active and
434-
/// [SliderThemeData.showValueIndicator] is satisfied.
433+
/// A label to show inside the value indicator above the slider's thumb.
435434
///
436-
/// It is used to display the value of a discrete slider, and it is displayed
437-
/// as part of the value indicator shape.
435+
/// By default, the label is shown while dragging a discrete slider, where
436+
/// [divisions] is non-null. It can also be shown for a continuous slider, where
437+
/// [divisions] is null, by setting [showValueIndicator] to
438+
/// [ShowValueIndicator.onlyForContinuous], [ShowValueIndicator.onDrag], or
439+
/// [ShowValueIndicator.alwaysVisible].
440+
///
441+
/// If [showValueIndicator] is null, the ambient
442+
/// [SliderThemeData.showValueIndicator] determines when the label is shown.
438443
///
439444
/// The label is rendered using the active [ThemeData]'s [TextTheme.bodyLarge]
440445
/// text style, with the theme data's [ColorScheme.onPrimary] color. The
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
changelog: |
2+
- Clarifies how `Slider.label` can be displayed for continuous sliders.
3+
version: patch

0 commit comments

Comments
 (0)