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
d99e5fdd
Unverified
Commit
d99e5fdd
authored
Jun 22, 2023
by
Taha Tesser
Committed by
GitHub
Jun 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `Slider` overlay remains when unfocused (#129115)
fixes
https://github.com/flutter/flutter/issues/129016
parent
bec24367
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
20 deletions
+29
-20
slider.dart
packages/flutter/lib/src/material/slider.dart
+1
-4
slider_test.dart
packages/flutter/test/material/slider_test.dart
+28
-16
No files found.
packages/flutter/lib/src/material/slider.dart
View file @
d99e5fdd
...
...
@@ -1530,10 +1530,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
onChangeEnd
?.
call
(
_discretize
(
_currentDragValue
));
_active
=
false
;
_currentDragValue
=
0.0
;
if
(!
hasFocus
)
{
_state
.
overlayController
.
reverse
();
}
_state
.
overlayController
.
reverse
();
if
(
showValueIndicator
&&
_state
.
interactionTimer
==
null
)
{
_state
.
valueIndicatorController
.
reverse
();
}
...
...
packages/flutter/test/material/slider_test.dart
View file @
d99e5fdd
...
...
@@ -1945,6 +1945,7 @@ void main() {
double
value
=
0.5
;
final
ThemeData
theme
=
ThemeData
(
useMaterial3:
true
);
final
Key
sliderKey
=
UniqueKey
();
final
FocusNode
focusNode
=
FocusNode
();
Widget
buildApp
({
bool
enabled
=
true
})
{
return
MaterialApp
(
...
...
@@ -1953,8 +1954,9 @@ void main() {
child:
Center
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Slider
(
value:
value
,
key:
sliderKey
,
value:
value
,
focusNode:
focusNode
,
onChanged:
enabled
?
(
double
newValue
)
{
setState
(()
{
...
...
@@ -1994,7 +1996,18 @@ void main() {
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
// Slider still has overlay when stopped dragging.
// Slider without focus doesn't have overlay when enabled and dragged.
expect
(
focusNode
.
hasFocus
,
false
);
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
))),
isNot
(
paints
..
circle
(
color:
theme
.
colorScheme
.
primary
.
withOpacity
(
0.12
))),
);
// Slider has overlay when enabled, dragged and focused.
focusNode
.
requestFocus
();
await
tester
.
pumpAndSettle
();
expect
(
focusNode
.
hasFocus
,
true
);
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
))),
paints
..
circle
(
color:
theme
.
colorScheme
.
primary
.
withOpacity
(
0.12
)),
...
...
@@ -2005,6 +2018,7 @@ void main() {
tester
.
binding
.
focusManager
.
highlightStrategy
=
FocusHighlightStrategy
.
alwaysTraditional
;
double
value
=
0.5
;
final
Key
sliderKey
=
UniqueKey
();
final
FocusNode
focusNode
=
FocusNode
();
Widget
buildApp
({
bool
enabled
=
true
})
{
return
MaterialApp
(
...
...
@@ -2012,8 +2026,9 @@ void main() {
child:
Center
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Slider
(
value:
value
,
key:
sliderKey
,
value:
value
,
focusNode:
focusNode
,
overlayColor:
MaterialStateColor
.
resolveWith
((
Set
<
MaterialState
>
states
)
{
if
(
states
.
contains
(
MaterialState
.
dragged
))
{
return
Colors
.
lime
[
500
]!;
...
...
@@ -2060,10 +2075,11 @@ void main() {
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
// Slider still has overlay when stopped dragging.
// Slider without focus doesn't have overlay when enabled and dragged.
expect
(
focusNode
.
hasFocus
,
false
);
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
))),
paints
..
circle
(
color:
Colors
.
lime
[
500
]
),
isNot
(
paints
..
circle
(
color:
Colors
.
lime
[
500
])
),
);
});
...
...
@@ -3495,14 +3511,7 @@ void main() {
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
focusNode
.
hasFocus
,
true
);
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
))),
paints
..
circle
(
color:
overlayColor
),
);
focusNode
.
unfocus
();
await
tester
.
pumpAndSettle
();
expect
(
focusNode
.
hasFocus
,
false
);
// Overlay is removed when adjusted with a tap.
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
))),
isNot
(
paints
..
circle
(
color:
overlayColor
)),
...
...
@@ -3796,6 +3805,7 @@ void main() {
double
value
=
0.5
;
final
ThemeData
theme
=
ThemeData
();
final
Key
sliderKey
=
UniqueKey
();
final
FocusNode
focusNode
=
FocusNode
();
Widget
buildApp
({
bool
enabled
=
true
})
{
return
MaterialApp
(
...
...
@@ -3803,8 +3813,9 @@ void main() {
child:
Center
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Slider
(
value:
value
,
key:
sliderKey
,
value:
value
,
focusNode:
focusNode
,
onChanged:
enabled
?
(
double
newValue
)
{
setState
(()
{
...
...
@@ -3844,10 +3855,11 @@ void main() {
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
// Slider still has overlay when stopped dragging.
// Slider without focus doesn't have overlay when enabled and dragged.
expect
(
focusNode
.
hasFocus
,
false
);
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
))),
paints
..
circle
(
color:
theme
.
colorScheme
.
primary
.
withOpacity
(
0.12
)),
isNot
(
paints
..
circle
(
color:
theme
.
colorScheme
.
primary
.
withOpacity
(
0.12
)
)),
);
});
});
...
...
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