Unverified Commit 7eb3df4a authored by Jose Alba's avatar Jose Alba Committed by GitHub

Default to use V2 Slider (#55599)

* Instead of changing test I just flipped flag so the test uses the proper slider

* Use Depracated annotation

* Updated depracation notice

* Updated depracation notice again

* Ignore analyze issues

* flutter analyze .

* ignore analyzer

* // ignore: deprecated_member_use

* Ignoring notice

* indentation
parent 7ab8767a
......@@ -305,6 +305,7 @@ class _ExpansionPanelsDemoState extends State<ExpansionPanelsDemo> {
// Allow room for the value indicator.
padding: const EdgeInsets.only(top: 44.0),
child: Slider(
// ignore: deprecated_member_use
useV2Slider: true,
min: 0.0,
max: 100.0,
......
......@@ -274,6 +274,7 @@ class _SlidersState extends State<_Sliders> {
),
),
Slider.adaptive(
// ignore: deprecated_member_use
useV2Slider: true,
label: _continuousValue.toStringAsFixed(6).toString(),
value: _continuousValue,
......@@ -291,6 +292,7 @@ class _SlidersState extends State<_Sliders> {
Column(
mainAxisSize: MainAxisSize.min,
children: const <Widget>[
// ignore: deprecated_member_use
Slider.adaptive(useV2Slider: true, value: 0.25, onChanged: null),
Text('Disabled'),
],
......@@ -299,6 +301,7 @@ class _SlidersState extends State<_Sliders> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Slider.adaptive(
// ignore: deprecated_member_use
useV2Slider: true,
value: _discreteValue,
min: 0.0,
......@@ -331,6 +334,7 @@ class _SlidersState extends State<_Sliders> {
valueIndicatorTextStyle: theme.accentTextTheme.bodyText1.copyWith(color: theme.colorScheme.onSurface),
),
child: Slider(
// ignore: deprecated_member_use
useV2Slider: true,
value: _discreteCustomValue,
min: 0.0,
......@@ -375,6 +379,7 @@ class _RangeSlidersState extends State<_RangeSliders> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RangeSlider(
// ignore: deprecated_member_use
useV2Slider: true,
values: _continuousValues,
min: 0.0,
......@@ -391,6 +396,7 @@ class _RangeSlidersState extends State<_RangeSliders> {
Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
// ignore: deprecated_member_use
RangeSlider(useV2Slider: true, values: const RangeValues(0.25, 0.75), onChanged: null),
const Text('Disabled'),
],
......@@ -399,6 +405,7 @@ class _RangeSlidersState extends State<_RangeSliders> {
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RangeSlider(
// ignore: deprecated_member_use
useV2Slider: true,
values: _discreteValues,
min: 0.0,
......@@ -429,6 +436,7 @@ class _RangeSlidersState extends State<_RangeSliders> {
showValueIndicator: ShowValueIndicator.never,
),
child: RangeSlider(
// ignore: deprecated_member_use
useV2Slider: true,
values: _discreteCustomValues,
min: 0.0,
......
......@@ -132,7 +132,12 @@ class RangeSlider extends StatefulWidget {
this.activeColor,
this.inactiveColor,
this.semanticFormatterCallback,
this.useV2Slider = 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,
}) : assert(values != null),
assert(min != null),
assert(max != null),
......@@ -141,6 +146,7 @@ class RangeSlider extends StatefulWidget {
assert(values.start >= min && values.start <= max),
assert(values.end >= min && values.end <= max),
assert(divisions == null || divisions > 0),
// ignore: deprecated_member_use_from_same_package
assert(useV2Slider != null),
super(key: key);
......@@ -351,6 +357,10 @@ class RangeSlider extends StatefulWidget {
/// 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.
......@@ -374,6 +384,7 @@ class RangeSlider extends StatefulWidget {
properties.add(StringProperty('labelEnd', labels?.end));
properties.add(ColorProperty('activeColor', activeColor));
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));
}
......@@ -562,6 +573,7 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
// the default shapes and text styles are aligned to the Material
// Guidelines.
// ignore: deprecated_member_use_from_same_package
final bool useV2Slider = widget.useV2Slider;
final double _defaultTrackHeight = useV2Slider ? 4 : 2;
final RangeSliderTrackShape _defaultTrackShape = RoundedRectRangeSliderTrackShape(useV2Slider: useV2Slider);
......@@ -631,6 +643,7 @@ class _RangeSliderState extends State<RangeSlider> with TickerProviderStateMixin
onChangeEnd: widget.onChangeEnd != null ? _handleDragEnd : null,
state: this,
semanticFormatterCallback: widget.semanticFormatterCallback,
// ignore: deprecated_member_use_from_same_package
useV2Slider: widget.useV2Slider,
),
);
......
......@@ -133,7 +133,12 @@ class Slider extends StatefulWidget {
this.semanticFormatterCallback,
this.focusNode,
this.autofocus = false,
this.useV2Slider = 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,
assert(value != null),
assert(min != null),
......@@ -141,6 +146,7 @@ class Slider extends StatefulWidget {
assert(min <= max),
assert(value >= min && value <= max),
assert(divisions == null || divisions > 0),
// ignore: deprecated_member_use_from_same_package
assert(useV2Slider != null),
super(key: key);
......@@ -166,7 +172,12 @@ class Slider extends StatefulWidget {
this.semanticFormatterCallback,
this.focusNode,
this.autofocus = false,
this.useV2Slider = 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,
assert(value != null),
assert(min != null),
......@@ -174,6 +185,7 @@ class Slider extends StatefulWidget {
assert(min <= max),
assert(value >= min && value <= max),
assert(divisions == null || divisions > 0),
// ignore: deprecated_member_use_from_same_package
assert(useV2Slider != null),
super(key: key);
......
......@@ -1673,9 +1673,13 @@ class RectangularSliderTrackShape extends SliderTrackShape with BaseSliderTrackS
/// * [RectangularSliderTrackShape], for a similar track with sharp edges.
class RoundedRectSliderTrackShape extends SliderTrackShape with BaseSliderTrackShape {
/// Create a slider track that draws two rectangles with rounded outer edges.
const RoundedRectSliderTrackShape({ this.useV2Slider = false });
const RoundedRectSliderTrackShape({ this.useV2Slider = true });
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
@override
......@@ -1739,6 +1743,7 @@ class RoundedRectSliderTrackShape extends SliderTrackShape with BaseSliderTrackS
final Radius trackRadius = Radius.circular(trackRect.height / 2);
final Radius activeTrackRadius = Radius.circular(trackRect.height / 2 + 1);
// ignore: deprecated_member_use_from_same_package
if (useV2Slider) {
context.canvas.drawRRect(
RRect.fromLTRBAndCorners(
......@@ -1813,6 +1818,10 @@ class RectangularRangeSliderTrackShape extends RangeSliderTrackShape {
const RectangularRangeSliderTrackShape({this.useV2Slider});
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
@override
......@@ -1942,6 +1951,10 @@ class RoundedRectRangeSliderTrackShape extends RangeSliderTrackShape {
const RoundedRectRangeSliderTrackShape({ this.useV2Slider });
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
@override
......@@ -2043,6 +2056,7 @@ class RoundedRectRangeSliderTrackShape extends RangeSliderTrackShape {
isDiscrete: isDiscrete,
);
// ignore: deprecated_member_use_from_same_package
if (useV2Slider) {
final Radius trackRadius = Radius.circular(trackRect.height / 2);
......@@ -2123,17 +2137,23 @@ class RoundSliderTickMarkShape extends SliderTickMarkShape {
/// Create a slider tick mark that draws a circle.
const RoundSliderTickMarkShape({
this.tickMarkRadius,
this.useV2Slider = false,
this.useV2Slider = true,
});
/// The preferred radius of the round tick mark.
///
// ignore: deprecated_member_use_from_same_package
/// If it is not provided, and [useV2Slider] is true, then 1/4 of the
/// [SliderThemeData.trackHeight] is used. If it is not provided, and
// ignore: deprecated_member_use_from_same_package
/// [useV2Slider] is false, then half of the track height is used.
final double tickMarkRadius;
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
@override
......@@ -2148,6 +2168,7 @@ class RoundSliderTickMarkShape extends SliderTickMarkShape {
// radius is defaulted to be a fraction of the
// [SliderThemeData.trackHeight]. The fraction is 1/4 when [useV2Slider] is
// true, and 1/2 when it is false.
// ignore: deprecated_member_use_from_same_package
return Size.fromRadius(tickMarkRadius ?? sliderTheme.trackHeight / (useV2Slider ? 4 : 2));
}
......@@ -2225,17 +2246,23 @@ class RoundRangeSliderTickMarkShape extends RangeSliderTickMarkShape {
/// Create a range slider tick mark that draws a circle.
const RoundRangeSliderTickMarkShape({
this.tickMarkRadius,
this.useV2Slider = false,
this.useV2Slider = true,
});
/// The preferred radius of the round tick mark.
///
// ignore: deprecated_member_use_from_same_package
/// If it is not provided, and [useV2Slider] is true, then 1/4 of the
/// [SliderThemeData.trackHeight] is used. If it is not provided, and
// ignore: deprecated_member_use_from_same_package
/// [useV2Slider] is false, then half of the track height is used.
final double tickMarkRadius;
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
@override
......@@ -2246,6 +2273,7 @@ class RoundRangeSliderTickMarkShape extends RangeSliderTickMarkShape {
assert(sliderTheme != null);
assert(sliderTheme.trackHeight != null);
assert(isEnabled != null);
// ignore: deprecated_member_use_from_same_package
return Size.fromRadius(tickMarkRadius ?? sliderTheme.trackHeight / (useV2Slider ? 4 : 2));
}
......@@ -2364,6 +2392,7 @@ class _EmptySliderComponentShape extends SliderComponentShape {
/// The default shape of a [Slider]'s thumb.
///
// ignore: deprecated_member_use_from_same_package
/// If [useV2Slider] is true, then there is a shadow for the resting and
/// pressed state.
///
......@@ -2379,7 +2408,7 @@ class RoundSliderThumbShape extends SliderComponentShape {
this.disabledThumbRadius,
this.elevation = 1.0,
this.pressedElevation = 6.0,
this.useV2Slider = false,
this.useV2Slider = true,
});
/// The preferred radius of the round thumb shape when the slider is enabled.
......@@ -2396,6 +2425,7 @@ class RoundSliderThumbShape extends SliderComponentShape {
/// The resting elevation adds shadow to the unpressed thumb.
///
// ignore: deprecated_member_use_from_same_package
/// This value is only used when [useV2Slider] is true.
///
/// The default is 1.
......@@ -2407,6 +2437,7 @@ class RoundSliderThumbShape extends SliderComponentShape {
/// The pressed elevation adds shadow to the pressed thumb.
///
// ignore: deprecated_member_use_from_same_package
/// This value is only used when [useV2Slider] is true.
///
/// The default is 6.
......@@ -2416,6 +2447,10 @@ class RoundSliderThumbShape extends SliderComponentShape {
final double pressedElevation;
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
@override
......@@ -2459,6 +2494,7 @@ class RoundSliderThumbShape extends SliderComponentShape {
final Color color = colorTween.evaluate(enableAnimation);
final double radius = radiusTween.evaluate(enableAnimation);
// ignore: deprecated_member_use_from_same_package
if (useV2Slider) {
final Tween<double> elevationTween = Tween<double>(
begin: elevation,
......@@ -2481,6 +2517,7 @@ class RoundSliderThumbShape extends SliderComponentShape {
/// The default shape of a [RangeSlider]'s thumbs.
///
// ignore: deprecated_member_use_from_same_package
/// If [useV2Slider] is true, then there is a shadow for the resting and
/// pressed state.
///
......@@ -2496,10 +2533,14 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape {
this.disabledThumbRadius,
this.elevation = 1.0,
this.pressedElevation = 6.0,
this.useV2Slider = false,
this.useV2Slider = true,
}) : assert(enabledThumbRadius != null);
/// {@macro flutter.material.slider.useV2Slider}
@Deprecated(
'This flag has changed to true by default and no longer needed. '
'This feature was deprecated after v1.18.0.'
)
final bool useV2Slider;
/// The preferred radius of the round thumb shape when the slider is enabled.
......@@ -2595,6 +2636,7 @@ class RoundRangeSliderThumbShape extends RangeSliderThumbShape {
final Color color = colorTween.evaluate(enableAnimation);
// ignore: deprecated_member_use_from_same_package
if (useV2Slider) {
final double evaluatedElevation = isPressed ? elevationTween.evaluate(activationAnimation) : elevation;
final Path shadowPath = Path()
......
......@@ -461,6 +461,8 @@ void main() {
final Widget slider = Scaffold(
body: Center(
child: Slider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
value: 0.5,
onChanged: (double value) { },
),
......
......@@ -1053,6 +1053,7 @@ void main() {
activeColor: activeColor,
inactiveColor: inactiveColor,
onChanged: onChanged,
// ignore: deprecated_member_use_from_same_package
useV2Slider: useV2Slider,
),
),
......@@ -1545,6 +1546,7 @@ void main() {
activeColor: activeColor,
inactiveColor: inactiveColor,
onChanged: onChanged,
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -1601,6 +1603,8 @@ void main() {
child: Theme(
data: theme,
child: RangeSlider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
values: values,
labels: RangeLabels(values.start.toStringAsFixed(2), values.end.toStringAsFixed(2)),
divisions: divisions,
......@@ -1686,6 +1690,7 @@ void main() {
values = newValues;
});
},
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -1829,6 +1834,7 @@ void main() {
values = newValues;
});
},
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -1982,6 +1988,7 @@ void main() {
values = newValues;
});
},
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -2105,6 +2112,8 @@ void main() {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
RangeSlider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
activeColor: Colors.blue,
divisions: 4,
inactiveColor: Colors.grey,
......
......@@ -641,6 +641,7 @@ void main() {
activeColor: activeColor,
inactiveColor: inactiveColor,
onChanged: onChanged,
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -857,6 +858,8 @@ void main() {
child: Theme(
data: theme,
child: Slider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
value: value,
label: '$value',
divisions: divisions,
......@@ -1232,6 +1235,7 @@ void main() {
value = newValue;
});
},
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -1368,6 +1372,8 @@ void main() {
maxWidth: double.infinity,
maxHeight: double.infinity,
child: Slider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
key: sliderKey,
min: 0.0,
max: 100.0,
......@@ -1507,6 +1513,7 @@ void main() {
value = newValue;
});
},
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
);
......@@ -1632,6 +1639,8 @@ void main() {
Widget buildSlider(int parents) {
Widget createParents(int parents, StateSetter setState) {
Widget slider = Slider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
key: sliderKey,
value: value,
divisions: 4,
......@@ -2496,6 +2505,8 @@ void main() {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const Slider(
// ignore: deprecated_member_use_from_same_package
useV2Slider: false,
activeColor: Colors.blue,
divisions: 10,
inactiveColor: Colors.grey,
......
......@@ -454,6 +454,7 @@ void main() {
label: value,
divisions: 3,
onChanged: (double d) { },
// ignore: deprecated_member_use_from_same_package
useV2Slider: true,
),
),
......@@ -1281,6 +1282,7 @@ Widget _buildApp(
label: '$value',
onChanged: onChanged,
divisions: divisions,
// ignore: deprecated_member_use_from_same_package
useV2Slider: useV2Slider
),
),
......
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