Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
0549ab23
Unverified
Commit
0549ab23
authored
Apr 30, 2020
by
Jose Alba
Committed by
GitHub
Apr 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed useV2 Slider flag (#55857)
parent
368da5bb
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
278 additions
and
1579 deletions
+278
-1579
range_slider.dart
packages/flutter/lib/src/material/range_slider.dart
+7
-45
slider.dart
packages/flutter/lib/src/material/slider.dart
+7
-47
slider_theme.dart
packages/flutter/lib/src/material/slider_theme.dart
+77
-202
inherited_theme_test.dart
packages/flutter/test/material/inherited_theme_test.dart
+2
-4
range_slider_test.dart
packages/flutter/test/material/range_slider_test.dart
+13
-564
slider_test.dart
packages/flutter/test/material/slider_test.dart
+51
-509
slider_theme_test.dart
packages/flutter/test/material/slider_theme_test.dart
+121
-208
No files found.
packages/flutter/lib/src/material/range_slider.dart
View file @
0549ab23
...
...
@@ -132,12 +132,6 @@ class RangeSlider extends StatefulWidget {
this
.
activeColor
,
this
.
inactiveColor
,
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
(
min
!=
null
),
assert
(
max
!=
null
),
...
...
@@ -146,8 +140,6 @@ 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
);
/// The currently selected values for this range slider.
...
...
@@ -346,23 +338,6 @@ class RangeSlider extends StatefulWidget {
/// {@end-tool}
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.
static
const
double
_minTouchTargetWidth
=
kMinInteractiveDimension
;
...
...
@@ -384,8 +359,6 @@ 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
));
}
}
...
...
@@ -573,14 +546,12 @@ 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
);
final
RangeSliderTickMarkShape
_defaultTickMarkShape
=
RoundRangeSliderTickMarkShape
(
useV2Slider:
useV2Slider
);
const
double
_defaultTrackHeight
=
4
;
const
RangeSliderTrackShape
_defaultTrackShape
=
RoundedRectRangeSliderTrackShape
();
const
RangeSliderTickMarkShape
_defaultTickMarkShape
=
RoundRangeSliderTickMarkShape
();
const
SliderComponentShape
_defaultOverlayShape
=
RoundSliderOverlayShape
();
final
RangeSliderThumbShape
_defaultThumbShape
=
RoundRangeSliderThumbShape
(
useV2Slider:
useV2Slider
);
final
RangeSliderValueIndicatorShape
_defaultValueIndicatorShape
=
useV2Slider
?
const
RectangularRangeSliderValueIndicatorShape
()
:
const
Paddle
RangeSliderValueIndicatorShape
();
const
RangeSliderThumbShape
_defaultThumbShape
=
RoundRangeSliderThumbShape
(
);
const
RangeSliderValueIndicatorShape
_defaultValueIndicatorShape
=
Rectangular
RangeSliderValueIndicatorShape
();
const
ShowValueIndicator
_defaultShowValueIndicator
=
ShowValueIndicator
.
onlyForDiscrete
;
const
double
_defaultMinThumbSeparation
=
8
;
...
...
@@ -643,8 +614,6 @@ 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
,
),
);
}
...
...
@@ -684,7 +653,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
this
.
onChangeEnd
,
this
.
state
,
this
.
semanticFormatterCallback
,
this
.
useV2Slider
,
})
:
super
(
key:
key
);
final
RangeValues
values
;
...
...
@@ -698,7 +666,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
final
ValueChanged
<
RangeValues
>
onChangeEnd
;
final
RangeSemanticFormatterCallback
semanticFormatterCallback
;
final
_RangeSliderState
state
;
final
bool
useV2Slider
;
@override
_RenderRangeSlider
createRenderObject
(
BuildContext
context
)
{
...
...
@@ -717,7 +684,6 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
textDirection:
Directionality
.
of
(
context
),
semanticFormatterCallback:
semanticFormatterCallback
,
platform:
Theme
.
of
(
context
).
platform
,
useV2Slider:
useV2Slider
,
);
}
...
...
@@ -756,7 +722,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
this
.
onChangeEnd
,
@required
_RangeSliderState
state
,
@required
TextDirection
textDirection
,
bool
useV2Slider
,
})
:
assert
(
values
!=
null
),
assert
(
values
.
start
>=
0.0
&&
values
.
start
<=
1.0
),
assert
(
values
.
end
>=
0.0
&&
values
.
end
<=
1.0
),
...
...
@@ -773,8 +738,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
_screenSize
=
screenSize
,
_onChanged
=
onChanged
,
_state
=
state
,
_textDirection
=
textDirection
,
_useV2Slider
=
useV2Slider
{
_textDirection
=
textDirection
{
_updateLabelPainters
();
final
GestureArenaTeam
team
=
GestureArenaTeam
();
_drag
=
HorizontalDragGestureRecognizer
()
...
...
@@ -1022,8 +986,6 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
return
0.05
;
}
final
bool
_useV2Slider
;
void
_updateLabelPainters
()
{
_updateLabelPainter
(
Thumb
.
start
);
_updateLabelPainter
(
Thumb
.
end
);
...
...
@@ -1351,7 +1313,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
isEnabled:
isEnabled
,
sliderTheme:
_sliderTheme
,
).
width
;
final
double
padding
=
_useV2Slider
?
trackRect
.
height
:
tickMarkWidth
;
final
double
padding
=
trackRect
.
height
;
final
double
adjustedTrackWidth
=
trackRect
.
width
-
padding
;
// If the tick marks would be too dense, don't bother painting them.
if
(
adjustedTrackWidth
/
divisions
>=
3.0
*
tickMarkWidth
)
{
...
...
packages/flutter/lib/src/material/slider.dart
View file @
0549ab23
...
...
@@ -133,12 +133,6 @@ class Slider extends StatefulWidget {
this
.
semanticFormatterCallback
,
this
.
focusNode
,
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
,
assert
(
value
!=
null
),
assert
(
min
!=
null
),
...
...
@@ -146,8 +140,6 @@ 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
);
/// Creates a [CupertinoSlider] if the target platform is iOS, creates a
...
...
@@ -172,12 +164,6 @@ class Slider extends StatefulWidget {
this
.
semanticFormatterCallback
,
this
.
focusNode
,
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
,
assert
(
value
!=
null
),
assert
(
min
!=
null
),
...
...
@@ -185,8 +171,6 @@ 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
);
/// The currently selected value for this slider.
...
...
@@ -407,20 +391,6 @@ class Slider extends StatefulWidget {
/// {@macro flutter.widgets.Focus.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
;
@override
...
...
@@ -442,7 +412,6 @@ class Slider extends StatefulWidget {
properties
.
add
(
ObjectFlagProperty
<
ValueChanged
<
double
>>.
has
(
'semanticFormatterCallback'
,
semanticFormatterCallback
));
properties
.
add
(
ObjectFlagProperty
<
FocusNode
>.
has
(
'focusNode'
,
focusNode
));
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 {
// the default shapes and text styles are aligned to the Material
// Guidelines.
final
bool
useV2Slider
=
widget
.
useV2Slider
;
final
double
_defaultTrackHeight
=
useV2Slider
?
4
:
2
;
final
SliderTrackShape
_defaultTrackShape
=
RoundedRectSliderTrackShape
(
useV2Slider:
useV2Slider
);
final
SliderTickMarkShape
_defaultTickMarkShape
=
RoundSliderTickMarkShape
(
useV2Slider:
useV2Slider
);
const
double
_defaultTrackHeight
=
4
;
const
SliderTrackShape
_defaultTrackShape
=
RoundedRectSliderTrackShape
();
const
SliderTickMarkShape
_defaultTickMarkShape
=
RoundSliderTickMarkShape
();
const
SliderComponentShape
_defaultOverlayShape
=
RoundSliderOverlayShape
();
final
SliderComponentShape
_defaultThumbShape
=
RoundSliderThumbShape
(
useV2Slider:
useV2Slider
);
final
SliderComponentShape
_defaultValueIndicatorShape
=
useV2Slider
?
const
RectangularSliderValueIndicatorShape
()
:
const
Paddle
SliderValueIndicatorShape
();
const
SliderComponentShape
_defaultThumbShape
=
RoundSliderThumbShape
(
);
const
SliderComponentShape
_defaultValueIndicatorShape
=
Rectangular
SliderValueIndicatorShape
();
const
ShowValueIndicator
_defaultShowValueIndicator
=
ShowValueIndicator
.
onlyForDiscrete
;
// 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 {
semanticFormatterCallback:
widget
.
semanticFormatterCallback
,
hasFocus:
_focused
,
hovering:
_hovering
,
useV2Slider:
widget
.
useV2Slider
,
),
),
);
...
...
@@ -774,7 +741,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
this
.
semanticFormatterCallback
,
this
.
hasFocus
,
this
.
hovering
,
this
.
useV2Slider
,
})
:
super
(
key:
key
);
final
double
value
;
...
...
@@ -790,7 +756,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
final
_SliderState
state
;
final
bool
hasFocus
;
final
bool
hovering
;
final
bool
useV2Slider
;
@override
_RenderSlider
createRenderObject
(
BuildContext
context
)
{
...
...
@@ -810,7 +775,6 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
platform:
Theme
.
of
(
context
).
platform
,
hasFocus:
hasFocus
,
hovering:
hovering
,
useV2Slider:
useV2Slider
,
);
}
...
...
@@ -854,7 +818,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
@required
TextDirection
textDirection
,
bool
hasFocus
,
bool
hovering
,
bool
useV2Slider
,
})
:
assert
(
value
!=
null
&&
value
>=
0.0
&&
value
<=
1.0
),
assert
(
state
!=
null
),
assert
(
textDirection
!=
null
),
...
...
@@ -870,8 +833,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
_state
=
state
,
_textDirection
=
textDirection
,
_hasFocus
=
hasFocus
,
_hovering
=
hovering
,
_useV2Slider
=
useV2Slider
{
_hovering
=
hovering
{
_updateLabelPainter
();
final
GestureArenaTeam
team
=
GestureArenaTeam
();
_drag
=
HorizontalDragGestureRecognizer
()
...
...
@@ -1116,8 +1078,6 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
}
}
}
final
bool
_useV2Slider
;
bool
get
showValueIndicator
{
bool
showValueIndicator
;
switch
(
_sliderTheme
.
showValueIndicator
)
{
...
...
@@ -1379,7 +1339,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
isEnabled:
isInteractive
,
sliderTheme:
_sliderTheme
,
).
width
;
final
double
padding
=
_useV2Slider
?
trackRect
.
height
:
tickMarkWidth
;
final
double
padding
=
trackRect
.
height
;
final
double
adjustedTrackWidth
=
trackRect
.
width
-
padding
;
// If the tick marks would be too dense, don't bother painting them.
if
(
adjustedTrackWidth
/
divisions
>=
3.0
*
tickMarkWidth
)
{
...
...
packages/flutter/lib/src/material/slider_theme.dart
View file @
0549ab23
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/inherited_theme_test.dart
View file @
0549ab23
...
...
@@ -461,8 +461,6 @@ 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
)
{
},
),
...
...
@@ -525,7 +523,7 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'push wrapped'
));
await
tester
.
pumpAndSettle
();
// route animation
RenderBox
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
expect
(
sliderBox
,
paints
..
r
ect
(
color:
activeTrackColor
)..
rect
(
color:
inactiveTrackColor
));
expect
(
sliderBox
,
paints
..
r
rect
(
color:
activeTrackColor
)..
r
rect
(
color:
inactiveTrackColor
));
expect
(
sliderBox
,
paints
..
circle
(
color:
thumbColor
));
Navigator
.
of
(
navigatorContext
).
pop
();
...
...
@@ -534,7 +532,7 @@ void main() {
await
tester
.
tap
(
find
.
text
(
'push unwrapped'
));
await
tester
.
pumpAndSettle
();
// route animation
sliderBox
=
tester
.
firstRenderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
expect
(
sliderBox
,
isNot
(
paints
..
r
ect
(
color:
activeTrackColor
)..
rect
(
color:
inactiveTrackColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
r
rect
(
color:
activeTrackColor
)..
r
rect
(
color:
inactiveTrackColor
)));
expect
(
sliderBox
,
isNot
(
paints
..
circle
(
color:
thumbColor
)));
});
...
...
packages/flutter/test/material/range_slider_test.dart
View file @
0549ab23
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/slider_test.dart
View file @
0549ab23
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/slider_theme_test.dart
View file @
0549ab23
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment