Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/material_ui/lib/src/slider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,9 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
config.label = label!;
}
config.isSlider = true;
config.role = SemanticsRole.slider;
config.minValue = _state.widget.min.toString();
config.maxValue = _state.widget.max.toString();
Comment on lines +1998 to +1999

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of accessing the widget's properties directly via _state.widget.min and _state.widget.max, it is more idiomatic to use the RenderObject's own min and max properties. This respects the encapsulation of the RenderObject and ensures consistency with how other properties are accessed.

    config.minValue = min.toString();
    config.maxValue = max.toString();

config.isFocusable = isInteractive;
config.isFocused = hasFocus;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changelog: |
- Adds `SemanticsRole.slider` and min/max value bounds to `Slider` semantics.
version: patch
6 changes: 6 additions & 0 deletions packages/material_ui/test/slider_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,9 @@ void main() {
increasedValue: '55%',
decreasedValue: '45%',
textDirection: TextDirection.ltr,
role: SemanticsRole.slider,
minValue: '0.0',
maxValue: '1.0',
),
],
),
Expand Down Expand Up @@ -1543,6 +1546,9 @@ void main() {
increasedValue: '60%',
decreasedValue: '40%',
textDirection: TextDirection.ltr,
role: SemanticsRole.slider,
minValue: '0.0',
maxValue: '200.0',
),
],
),
Expand Down
Loading