@@ -558,16 +558,10 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
558558 // thumb selection is determined by the direction of the dx. The left thumb
559559 // is chosen for negative dx, and the right thumb is chosen for positive dx.
560560 if (inStartTouchTarget && inEndTouchTarget) {
561- final bool towardsStart;
562- final bool towardsEnd;
563- switch (textDirection) {
564- case TextDirection .ltr:
565- towardsStart = dx < 0 ;
566- towardsEnd = dx > 0 ;
567- case TextDirection .rtl:
568- towardsStart = dx > 0 ;
569- towardsEnd = dx < 0 ;
570- }
561+ final (bool towardsStart, bool towardsEnd) = switch (textDirection) {
562+ TextDirection .ltr => (dx < 0 , dx > 0 ),
563+ TextDirection .rtl => (dx > 0 , dx < 0 ),
564+ };
571565 if (towardsStart) {
572566 return Thumb .start;
573567 }
@@ -1102,16 +1096,12 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
11021096 }
11031097
11041098 bool get showValueIndicator {
1105- switch (_sliderTheme.showValueIndicator! ) {
1106- case ShowValueIndicator .onlyForDiscrete:
1107- return isDiscrete;
1108- case ShowValueIndicator .onlyForContinuous:
1109- return ! isDiscrete;
1110- case ShowValueIndicator .always:
1111- return true ;
1112- case ShowValueIndicator .never:
1113- return false ;
1114- }
1099+ return switch (_sliderTheme.showValueIndicator! ) {
1100+ ShowValueIndicator .onlyForDiscrete => isDiscrete,
1101+ ShowValueIndicator .onlyForContinuous => ! isDiscrete,
1102+ ShowValueIndicator .always => true ,
1103+ ShowValueIndicator .never => false ,
1104+ };
11151105 }
11161106
11171107 Size get _thumbSize => _sliderTheme.rangeThumbShape! .getPreferredSize (isEnabled, isDiscrete);
@@ -1142,16 +1132,10 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
11421132 return ;
11431133 }
11441134
1145- final String text;
1146- final TextPainter labelPainter;
1147- switch (thumb) {
1148- case Thumb .start:
1149- text = labels.start;
1150- labelPainter = _startLabelPainter;
1151- case Thumb .end:
1152- text = labels.end;
1153- labelPainter = _endLabelPainter;
1154- }
1135+ final (String text, TextPainter labelPainter) = switch (thumb) {
1136+ Thumb .start => (labels.start, _startLabelPainter),
1137+ Thumb .end => (labels.end, _endLabelPainter),
1138+ };
11551139
11561140 labelPainter
11571141 ..text = TextSpan (
@@ -1205,12 +1189,10 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
12051189 }
12061190
12071191 double _getValueFromVisualPosition (double visualPosition) {
1208- switch (textDirection) {
1209- case TextDirection .rtl:
1210- return 1.0 - visualPosition;
1211- case TextDirection .ltr:
1212- return visualPosition;
1213- }
1192+ return switch (textDirection) {
1193+ TextDirection .rtl => 1.0 - visualPosition,
1194+ TextDirection .ltr => visualPosition,
1195+ };
12141196 }
12151197
12161198 double _getValueFromGlobalPosition (Offset globalPosition) {
@@ -1399,16 +1381,10 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
13991381 // The visual position is the position of the thumb from 0 to 1 from left
14001382 // to right. In left to right, this is the same as the value, but it is
14011383 // reversed for right to left text.
1402- final double startVisualPosition;
1403- final double endVisualPosition;
1404- switch (textDirection) {
1405- case TextDirection .rtl:
1406- startVisualPosition = 1.0 - startValue;
1407- endVisualPosition = 1.0 - endValue;
1408- case TextDirection .ltr:
1409- startVisualPosition = startValue;
1410- endVisualPosition = endValue;
1411- }
1384+ final (double startVisualPosition, double endVisualPosition) = switch (textDirection) {
1385+ TextDirection .rtl => (1.0 - startValue, 1.0 - endValue),
1386+ TextDirection .ltr => (startValue, endValue),
1387+ };
14121388
14131389 final Rect trackRect = _sliderTheme.rangeTrackShape! .getPreferredRect (
14141390 parentBox: this ,
@@ -1585,15 +1561,10 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
15851561 labelPainter: _endLabelPainter,
15861562 textScaleFactor: textScaleFactor,
15871563 ).width / 2 ;
1588- double innerOverflow = startHalfWidth + endHalfWidth;
1589- switch (textDirection) {
1590- case TextDirection .ltr:
1591- innerOverflow += startOffset;
1592- innerOverflow -= endOffset;
1593- case TextDirection .rtl:
1594- innerOverflow -= startOffset;
1595- innerOverflow += endOffset;
1596- }
1564+ final double innerOverflow = startHalfWidth + endHalfWidth + switch (textDirection) {
1565+ TextDirection .ltr => startOffset - endOffset,
1566+ TextDirection .rtl => endOffset - startOffset,
1567+ };
15971568
15981569 _state.paintTopValueIndicator = (PaintingContext context, Offset offset) {
15991570 if (attached) {
0 commit comments