Unverified Commit 629395f7 authored by Pierre-Louis's avatar Pierre-Louis Committed by GitHub

Add per thumb Range Slider semantics (#61439)

parent 6d303af9
...@@ -28,13 +28,6 @@ import 'theme.dart'; ...@@ -28,13 +28,6 @@ import 'theme.dart';
// int _duelCommandment = 1; // int _duelCommandment = 1;
// void setState(VoidCallback fn) { } // void setState(VoidCallback fn) { }
/// A callback that formats a numeric value from a [Slider] widget.
///
/// See also:
///
/// * [Slider.semanticFormatterCallback], which shows an example use case.
typedef SemanticFormatterCallback = String Function(double value);
/// [Slider] uses this callback to paint the value indicator on the overlay. /// [Slider] uses this callback to paint the value indicator on the overlay.
/// ///
/// Since the value indicator is painted on the Overlay; this method paints the /// Since the value indicator is painted on the Overlay; this method paints the
......
...@@ -3307,12 +3307,13 @@ class _PaddleSliderValueIndicatorPathPainter { ...@@ -3307,12 +3307,13 @@ class _PaddleSliderValueIndicatorPathPainter {
} }
} }
/// A callback that formats the numeric values from a [RangeSlider] widget. /// A callback that formats a numeric value from a [Slider] or [RangerSlider] widget.
/// ///
/// See also: /// See also:
/// ///
/// * [Slider.semanticFormatterCallback], which shows an example use case.
/// * [RangeSlider.semanticFormatterCallback], which shows an example use case. /// * [RangeSlider.semanticFormatterCallback], which shows an example use case.
typedef RangeSemanticFormatterCallback = String Function(RangeValues values); typedef SemanticFormatterCallback = String Function(double value);
/// Decides which thumbs (if any) should be selected. /// Decides which thumbs (if any) should be selected.
/// ///
......
...@@ -1742,6 +1742,63 @@ void main() { ...@@ -1742,6 +1742,63 @@ void main() {
); );
}); });
testWidgets('Range Slider Semantics', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Theme(
data: ThemeData.light(),
child: Directionality(
textDirection: TextDirection.ltr,
child: MediaQuery(
data: MediaQueryData.fromWindow(window),
child: Material(
child: RangeSlider(
values: const RangeValues(10.0, 12.0),
min: 0.0,
max: 100.0,
onChanged: (RangeValues v) { },
),
),
),
),
),
)
);
await tester.pumpAndSettle();
expect(
tester.getSemantics(find.byType(RangeSlider)),
matchesSemantics(
scopesRoute: true,
children:<Matcher>[
matchesSemantics(
children: <Matcher>[
matchesSemantics(
isEnabled: true,
hasEnabledState: true,
hasIncreaseAction: true,
hasDecreaseAction: true,
value: '10%',
increasedValue: '10%',
decreasedValue: '5%',
),
matchesSemantics(
isEnabled: true,
hasEnabledState: true,
hasIncreaseAction: true,
hasDecreaseAction: true,
value: '12%',
increasedValue: '17%',
decreasedValue: '12%',
),
],
),
],
),
);
});
testWidgets('Range Slider implements debugFillProperties', (WidgetTester tester) async { testWidgets('Range Slider implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment