Unverified Commit 0549ab23 authored by Jose Alba's avatar Jose Alba Committed by GitHub

Removed useV2 Slider flag (#55857)

parent 368da5bb
...@@ -132,12 +132,6 @@ class RangeSlider extends StatefulWidget { ...@@ -132,12 +132,6 @@ class RangeSlider extends StatefulWidget {
this.activeColor, this.activeColor,
this.inactiveColor, this.inactiveColor,
this.semanticFormatterCallback, this.semanticFormatterCallback,
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
// ignore: deprecated_member_use_from_same_package
this.useV2Slider = true,
}) : assert(values != null), }) : assert(values != null),
assert(min != null), assert(min != null),
assert(max != null), assert(max != null),
...@@ -146,8 +140,6 @@ class RangeSlider extends StatefulWidget { ...@@ -146,8 +140,6 @@ class RangeSlider extends StatefulWidget {
assert(values.start >= min && values.start <= max), assert(values.start >= min && values.start <= max),
assert(values.end >= min && values.end <= max), assert(values.end >= min && values.end <= max),
assert(divisions == null || divisions > 0), assert(divisions == null || divisions > 0),
// ignore: deprecated_member_use_from_same_package
assert(useV2Slider != null),
super(key: key); super(key: key);
/// The currently selected values for this range slider. /// The currently selected values for this range slider.
...@@ -346,23 +338,6 @@ class RangeSlider extends StatefulWidget { ...@@ -346,23 +338,6 @@ class RangeSlider extends StatefulWidget {
/// {@end-tool} /// {@end-tool}
final RangeSemanticFormatterCallback semanticFormatterCallback; final RangeSemanticFormatterCallback semanticFormatterCallback;
/// Whether to use the updated Material spec version of the [RangeSlider].
/// * The v2 [RangeSlider] has an updated value indicator that matches the latest specs.
/// * The value indicator is painted on the Overlay.
/// * The active track is bigger than the inactive track.
/// * The thumb that is activated has elevation.
/// * Updated value indicators in case they overlap with each other.
/// * <https://groups.google.com/g/flutter-announce/c/69dmlKUL5Ew/m/tQh-ajiEAAAJl>
///
/// This is a temporary flag for migrating the slider from v1 to v2. Currently
/// this defaults to false, because the changes may break existing tests. This
/// value will be defaulted to true in the future.
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
// Touch width for the tap boundary of the slider thumbs. // Touch width for the tap boundary of the slider thumbs.
static const double _minTouchTargetWidth = kMinInteractiveDimension; static const double _minTouchTargetWidth = kMinInteractiveDimension;
...@@ -384,8 +359,6 @@ class RangeSlider extends StatefulWidget { ...@@ -384,8 +359,6 @@ class RangeSlider extends StatefulWidget {
properties.add(StringProperty('labelEnd', labels?.end)); properties.add(StringProperty('labelEnd', labels?.end));
properties.add(ColorProperty('activeColor', activeColor)); properties.add(ColorProperty('activeColor', activeColor));
properties.add(ColorProperty('inactiveColor', inactiveColor)); properties.add(ColorProperty('inactiveColor', inactiveColor));
// ignore: deprecated_member_use_from_same_package
properties.add(FlagProperty('useV2Slider', value: useV2Slider, ifFalse: 'useV1Slider'));
properties.add(ObjectFlagProperty<ValueChanged<RangeValues>>.has('semanticFormatterCallback', semanticFormatterCallback)); properties.add(ObjectFlagProperty<ValueChanged<RangeValues>>.has('semanticFormatterCallback', semanticFormatterCallback));
} }
} }
...@@ -573,14 +546,12 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin ...@@ -573,14 +546,12 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
// the default shapes and text styles are aligned to the Material // the default shapes and text styles are aligned to the Material
// Guidelines. // Guidelines.
// ignore: deprecated_member_use_from_same_package const double _defaultTrackHeight = 4;
final bool useV2Slider = widget.useV2Slider; const RangeSliderTrackShape _defaultTrackShape = RoundedRectRangeSliderTrackShape();
final double _defaultTrackHeight = useV2Slider ? 4 : 2; const RangeSliderTickMarkShape _defaultTickMarkShape = RoundRangeSliderTickMarkShape();
final RangeSliderTrackShape _defaultTrackShape = RoundedRectRangeSliderTrackShape(useV2Slider: useV2Slider);
final RangeSliderTickMarkShape _defaultTickMarkShape = RoundRangeSliderTickMarkShape(useV2Slider: useV2Slider);
const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape(); const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape();
final RangeSliderThumbShape _defaultThumbShape = RoundRangeSliderThumbShape(useV2Slider: useV2Slider); const RangeSliderThumbShape _defaultThumbShape = RoundRangeSliderThumbShape();
final RangeSliderValueIndicatorShape _defaultValueIndicatorShape = useV2Slider ? const RectangularRangeSliderValueIndicatorShape() : const PaddleRangeSliderValueIndicatorShape(); const RangeSliderValueIndicatorShape _defaultValueIndicatorShape = RectangularRangeSliderValueIndicatorShape();
const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete; const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
const double _defaultMinThumbSeparation = 8; const double _defaultMinThumbSeparation = 8;
...@@ -643,8 +614,6 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin ...@@ -643,8 +614,6 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : null, onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : null,
state: this, state: this,
semanticFormatterCallback: widget.semanticFormatterCallback, semanticFormatterCallback: widget.semanticFormatterCallback,
// ignore: deprecated_member_use_from_same_package
useV2Slider: widget.useV2Slider,
), ),
); );
} }
...@@ -684,7 +653,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -684,7 +653,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
this.onChangeEnd, this.onChangeEnd,
this.state, this.state,
this.semanticFormatterCallback, this.semanticFormatterCallback,
this.useV2Slider,
}) : super(key: key); }) : super(key: key);
final RangeValues values; final RangeValues values;
...@@ -698,7 +666,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -698,7 +666,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
final ValueChanged<RangeValues> onChangeEnd; final ValueChanged<RangeValues> onChangeEnd;
final RangeSemanticFormatterCallback semanticFormatterCallback; final RangeSemanticFormatterCallback semanticFormatterCallback;
final _RangeSliderState state; final _RangeSliderState state;
final bool useV2Slider;
@override @override
_RenderRangeSlider createRenderObject(BuildContext context) { _RenderRangeSlider createRenderObject(BuildContext context) {
...@@ -717,7 +684,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -717,7 +684,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
textDirection: Directionality.of(context), textDirection: Directionality.of(context),
semanticFormatterCallback: semanticFormatterCallback, semanticFormatterCallback: semanticFormatterCallback,
platform: Theme.of(context).platform, platform: Theme.of(context).platform,
useV2Slider: useV2Slider,
); );
} }
...@@ -756,7 +722,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -756,7 +722,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
this.onChangeEnd, this.onChangeEnd,
@required _RangeSliderState state, @required _RangeSliderState state,
@required TextDirection textDirection, @required TextDirection textDirection,
bool useV2Slider,
}) : assert(values != null), }) : assert(values != null),
assert(values.start >= 0.0 && values.start <= 1.0), assert(values.start >= 0.0 && values.start <= 1.0),
assert(values.end >= 0.0 && values.end <= 1.0), assert(values.end >= 0.0 && values.end <= 1.0),
...@@ -773,8 +738,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -773,8 +738,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
_screenSize = screenSize, _screenSize = screenSize,
_onChanged = onChanged, _onChanged = onChanged,
_state = state, _state = state,
_textDirection = textDirection, _textDirection = textDirection {
_useV2Slider = useV2Slider {
_updateLabelPainters(); _updateLabelPainters();
final GestureArenaTeam team = GestureArenaTeam(); final GestureArenaTeam team = GestureArenaTeam();
_drag = HorizontalDragGestureRecognizer() _drag = HorizontalDragGestureRecognizer()
...@@ -1022,8 +986,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -1022,8 +986,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
return 0.05; return 0.05;
} }
final bool _useV2Slider;
void _updateLabelPainters() { void _updateLabelPainters() {
_updateLabelPainter(Thumb.start); _updateLabelPainter(Thumb.start);
_updateLabelPainter(Thumb.end); _updateLabelPainter(Thumb.end);
...@@ -1351,7 +1313,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix ...@@ -1351,7 +1313,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
isEnabled: isEnabled, isEnabled: isEnabled,
sliderTheme: _sliderTheme, sliderTheme: _sliderTheme,
).width; ).width;
final double padding = _useV2Slider ? trackRect.height : tickMarkWidth; final double padding = trackRect.height;
final double adjustedTrackWidth = trackRect.width - padding; final double adjustedTrackWidth = trackRect.width - padding;
// If the tick marks would be too dense, don't bother painting them. // If the tick marks would be too dense, don't bother painting them.
if (adjustedTrackWidth / divisions >= 3.0 * tickMarkWidth) { if (adjustedTrackWidth / divisions >= 3.0 * tickMarkWidth) {
......
...@@ -133,12 +133,6 @@ class Slider extends StatefulWidget { ...@@ -133,12 +133,6 @@ class Slider extends StatefulWidget {
this.semanticFormatterCallback, this.semanticFormatterCallback,
this.focusNode, this.focusNode,
this.autofocus = false, this.autofocus = false,
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
// ignore: deprecated_member_use_from_same_package
this.useV2Slider = true,
}) : _sliderType = _SliderType.material, }) : _sliderType = _SliderType.material,
assert(value != null), assert(value != null),
assert(min != null), assert(min != null),
...@@ -146,8 +140,6 @@ class Slider extends StatefulWidget { ...@@ -146,8 +140,6 @@ class Slider extends StatefulWidget {
assert(min <= max), assert(min <= max),
assert(value >= min && value <= max), assert(value >= min && value <= max),
assert(divisions == null || divisions > 0), assert(divisions == null || divisions > 0),
// ignore: deprecated_member_use_from_same_package
assert(useV2Slider != null),
super(key: key); super(key: key);
/// Creates a [CupertinoSlider] if the target platform is iOS, creates a /// Creates a [CupertinoSlider] if the target platform is iOS, creates a
...@@ -172,12 +164,6 @@ class Slider extends StatefulWidget { ...@@ -172,12 +164,6 @@ class Slider extends StatefulWidget {
this.semanticFormatterCallback, this.semanticFormatterCallback,
this.focusNode, this.focusNode,
this.autofocus = false, this.autofocus = false,
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
// ignore: deprecated_member_use_from_same_package
this.useV2Slider = true,
}) : _sliderType = _SliderType.adaptive, }) : _sliderType = _SliderType.adaptive,
assert(value != null), assert(value != null),
assert(min != null), assert(min != null),
...@@ -185,8 +171,6 @@ class Slider extends StatefulWidget { ...@@ -185,8 +171,6 @@ class Slider extends StatefulWidget {
assert(min <= max), assert(min <= max),
assert(value >= min && value <= max), assert(value >= min && value <= max),
assert(divisions == null || divisions > 0), assert(divisions == null || divisions > 0),
// ignore: deprecated_member_use_from_same_package
assert(useV2Slider != null),
super(key: key); super(key: key);
/// The currently selected value for this slider. /// The currently selected value for this slider.
...@@ -407,20 +391,6 @@ class Slider extends StatefulWidget { ...@@ -407,20 +391,6 @@ class Slider extends StatefulWidget {
/// {@macro flutter.widgets.Focus.autofocus} /// {@macro flutter.widgets.Focus.autofocus}
final bool autofocus; final bool autofocus;
/// Whether to use the updated Material spec version of the [Slider].
///
/// * The v2 Slider has an updated value indicator that matches the latest specs.
/// * The value indicator is painted on the Overlay.
/// * The active track is bigger than the inactive track.
/// * The thumb that is activated has elevation.
/// * Updated value indicators in case they overlap with each other.
/// * <https://groups.google.com/g/flutter-announce/c/69dmlKUL5Ew/m/tQh-ajiEAAAJl>
///
/// This is a temporary flag for migrating the slider from v1 to v2. To avoid
/// unexpected breaking changes, this value should be set to true. Setting
/// this to false is considered deprecated.
final bool useV2Slider;
final _SliderType _sliderType ; final _SliderType _sliderType ;
@override @override
...@@ -442,7 +412,6 @@ class Slider extends StatefulWidget { ...@@ -442,7 +412,6 @@ class Slider extends StatefulWidget {
properties.add(ObjectFlagProperty<ValueChanged<double>>.has('semanticFormatterCallback', semanticFormatterCallback)); properties.add(ObjectFlagProperty<ValueChanged<double>>.has('semanticFormatterCallback', semanticFormatterCallback));
properties.add(ObjectFlagProperty<FocusNode>.has('focusNode', focusNode)); properties.add(ObjectFlagProperty<FocusNode>.has('focusNode', focusNode));
properties.add(FlagProperty('autofocus', value: autofocus, ifTrue: 'autofocus')); properties.add(FlagProperty('autofocus', value: autofocus, ifTrue: 'autofocus'));
properties.add(FlagProperty('useV2Slider', value: useV2Slider, ifFalse: 'useV1Slider'));
} }
} }
...@@ -636,13 +605,12 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin { ...@@ -636,13 +605,12 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
// the default shapes and text styles are aligned to the Material // the default shapes and text styles are aligned to the Material
// Guidelines. // Guidelines.
final bool useV2Slider = widget.useV2Slider; const double _defaultTrackHeight = 4;
final double _defaultTrackHeight = useV2Slider ? 4 : 2; const SliderTrackShape _defaultTrackShape = RoundedRectSliderTrackShape();
final SliderTrackShape _defaultTrackShape = RoundedRectSliderTrackShape(useV2Slider: useV2Slider); const SliderTickMarkShape _defaultTickMarkShape = RoundSliderTickMarkShape();
final SliderTickMarkShape _defaultTickMarkShape = RoundSliderTickMarkShape(useV2Slider: useV2Slider);
const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape(); const SliderComponentShape _defaultOverlayShape = RoundSliderOverlayShape();
final SliderComponentShape _defaultThumbShape = RoundSliderThumbShape(useV2Slider: useV2Slider); const SliderComponentShape _defaultThumbShape = RoundSliderThumbShape();
final SliderComponentShape _defaultValueIndicatorShape = useV2Slider ? const RectangularSliderValueIndicatorShape() : const PaddleSliderValueIndicatorShape(); const SliderComponentShape _defaultValueIndicatorShape = RectangularSliderValueIndicatorShape();
const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete; const ShowValueIndicator _defaultShowValueIndicator = ShowValueIndicator.onlyForDiscrete;
// The value indicator's color is not the same as the thumb and active track // The value indicator's color is not the same as the thumb and active track
...@@ -712,7 +680,6 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin { ...@@ -712,7 +680,6 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
semanticFormatterCallback: widget.semanticFormatterCallback, semanticFormatterCallback: widget.semanticFormatterCallback,
hasFocus: _focused, hasFocus: _focused,
hovering: _hovering, hovering: _hovering,
useV2Slider: widget.useV2Slider,
), ),
), ),
); );
...@@ -774,7 +741,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -774,7 +741,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
this.semanticFormatterCallback, this.semanticFormatterCallback,
this.hasFocus, this.hasFocus,
this.hovering, this.hovering,
this.useV2Slider,
}) : super(key: key); }) : super(key: key);
final double value; final double value;
...@@ -790,7 +756,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -790,7 +756,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
final _SliderState state; final _SliderState state;
final bool hasFocus; final bool hasFocus;
final bool hovering; final bool hovering;
final bool useV2Slider;
@override @override
_RenderSlider createRenderObject(BuildContext context) { _RenderSlider createRenderObject(BuildContext context) {
...@@ -810,7 +775,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget { ...@@ -810,7 +775,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
platform: Theme.of(context).platform, platform: Theme.of(context).platform,
hasFocus: hasFocus, hasFocus: hasFocus,
hovering: hovering, hovering: hovering,
useV2Slider: useV2Slider,
); );
} }
...@@ -854,7 +818,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -854,7 +818,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
@required TextDirection textDirection, @required TextDirection textDirection,
bool hasFocus, bool hasFocus,
bool hovering, bool hovering,
bool useV2Slider,
}) : assert(value != null && value >= 0.0 && value <= 1.0), }) : assert(value != null && value >= 0.0 && value <= 1.0),
assert(state != null), assert(state != null),
assert(textDirection != null), assert(textDirection != null),
...@@ -870,8 +833,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -870,8 +833,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
_state = state, _state = state,
_textDirection = textDirection, _textDirection = textDirection,
_hasFocus = hasFocus, _hasFocus = hasFocus,
_hovering = hovering, _hovering = hovering {
_useV2Slider = useV2Slider {
_updateLabelPainter(); _updateLabelPainter();
final GestureArenaTeam team = GestureArenaTeam(); final GestureArenaTeam team = GestureArenaTeam();
_drag = HorizontalDragGestureRecognizer() _drag = HorizontalDragGestureRecognizer()
...@@ -1116,8 +1078,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -1116,8 +1078,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
} }
} }
} }
final bool _useV2Slider;
bool get showValueIndicator { bool get showValueIndicator {
bool showValueIndicator; bool showValueIndicator;
switch (_sliderTheme.showValueIndicator) { switch (_sliderTheme.showValueIndicator) {
...@@ -1379,7 +1339,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin { ...@@ -1379,7 +1339,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
isEnabled: isInteractive, isEnabled: isInteractive,
sliderTheme: _sliderTheme, sliderTheme: _sliderTheme,
).width; ).width;
final double padding = _useV2Slider ? trackRect.height : tickMarkWidth; final double padding = trackRect.height;
final double adjustedTrackWidth = trackRect.width - padding; final double adjustedTrackWidth = trackRect.width - padding;
// If the tick marks would be too dense, don't bother painting them. // If the tick marks would be too dense, don't bother painting them.
if (adjustedTrackWidth / divisions >= 3.0 * tickMarkWidth) { if (adjustedTrackWidth / divisions >= 3.0 * tickMarkWidth) {
......
...@@ -461,8 +461,6 @@ void main() { ...@@ -461,8 +461,6 @@ void main() {
final Widget slider = Scaffold( final Widget slider = Scaffold(
body: Center( body: Center(
child: Slider( child: Slider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
value: 0.5, value: 0.5,
onChanged: (double value) { }, onChanged: (double value) { },
), ),
...@@ -525,7 +523,7 @@ void main() { ...@@ -525,7 +523,7 @@ void main() {
await tester.tap(find.text('push wrapped')); await tester.tap(find.text('push wrapped'));
await tester.pumpAndSettle(); // route animation await tester.pumpAndSettle(); // route animation
RenderBox sliderBox = tester.firstRenderObject<RenderBox>(find.byType(Slider)); RenderBox sliderBox = tester.firstRenderObject<RenderBox>(find.byType(Slider));
expect(sliderBox, paints..rect(color: activeTrackColor)..rect(color: inactiveTrackColor)); expect(sliderBox, paints..rrect(color: activeTrackColor)..rrect(color: inactiveTrackColor));
expect(sliderBox, paints..circle(color: thumbColor)); expect(sliderBox, paints..circle(color: thumbColor));
Navigator.of(navigatorContext).pop(); Navigator.of(navigatorContext).pop();
...@@ -534,7 +532,7 @@ void main() { ...@@ -534,7 +532,7 @@ void main() {
await tester.tap(find.text('push unwrapped')); await tester.tap(find.text('push unwrapped'));
await tester.pumpAndSettle(); // route animation await tester.pumpAndSettle(); // route animation
sliderBox = tester.firstRenderObject<RenderBox>(find.byType(Slider)); sliderBox = tester.firstRenderObject<RenderBox>(find.byType(Slider));
expect(sliderBox, isNot(paints..rect(color: activeTrackColor)..rect(color: inactiveTrackColor))); expect(sliderBox, isNot(paints..rrect(color: activeTrackColor)..rrect(color: inactiveTrackColor)));
expect(sliderBox, isNot(paints..circle(color: thumbColor))); expect(sliderBox, isNot(paints..circle(color: thumbColor)));
}); });
......
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