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
49604926
Unverified
Commit
49604926
authored
May 12, 2022
by
Jonah Williams
Committed by
GitHub
May 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] fix slider regression due to touch slop changes (#103569)
parent
8bec125a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
3 deletions
+122
-3
slider.dart
packages/flutter/lib/src/material/slider.dart
+14
-3
slider_test.dart
packages/flutter/test/material/slider_test.dart
+108
-0
No files found.
packages/flutter/lib/src/material/slider.dart
View file @
49604926
...
...
@@ -881,6 +881,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
platform:
Theme
.
of
(
context
).
platform
,
hasFocus:
hasFocus
,
hovering:
hovering
,
gestureSettings:
MediaQuery
.
of
(
context
).
gestureSettings
,
);
}
...
...
@@ -902,7 +903,8 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
..
semanticFormatterCallback
=
semanticFormatterCallback
..
platform
=
Theme
.
of
(
context
).
platform
..
hasFocus
=
hasFocus
..
hovering
=
hovering
;
..
hovering
=
hovering
..
gestureSettings
=
MediaQuery
.
of
(
context
).
gestureSettings
;
// Ticker provider cannot change since there's a 1:1 relationship between
// the _SliderRenderObjectWidget object and the _SliderState object.
}
...
...
@@ -925,6 +927,7 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
required
TextDirection
textDirection
,
required
bool
hasFocus
,
required
bool
hovering
,
required
DeviceGestureSettings
gestureSettings
,
})
:
assert
(
value
!=
null
&&
value
>=
0.0
&&
value
<=
1.0
),
assert
(
state
!=
null
),
assert
(
textDirection
!=
null
),
...
...
@@ -948,11 +951,13 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
..
onStart
=
_handleDragStart
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
..
onCancel
=
_endInteraction
;
..
onCancel
=
_endInteraction
..
gestureSettings
=
gestureSettings
;
_tap
=
TapGestureRecognizer
()
..
team
=
team
..
onTapDown
=
_handleTapDown
..
onTapUp
=
_handleTapUp
;
..
onTapUp
=
_handleTapUp
..
gestureSettings
=
gestureSettings
;
_overlayAnimation
=
CurvedAnimation
(
parent:
_state
.
overlayController
,
curve:
Curves
.
fastOutSlowIn
,
...
...
@@ -1037,6 +1042,12 @@ class _RenderSlider extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
markNeedsSemanticsUpdate
();
}
DeviceGestureSettings
?
get
gestureSettings
=>
_drag
.
gestureSettings
;
set
gestureSettings
(
DeviceGestureSettings
?
gestureSettings
)
{
_drag
.
gestureSettings
=
gestureSettings
;
_tap
.
gestureSettings
=
gestureSettings
;
}
TargetPlatform
_platform
;
TargetPlatform
get
platform
=>
_platform
;
set
platform
(
TargetPlatform
value
)
{
...
...
packages/flutter/test/material/slider_test.dart
View file @
49604926
...
...
@@ -6,6 +6,7 @@ import 'dart:ui';
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/scheduler.dart'
;
...
...
@@ -2998,4 +2999,111 @@ void main() {
paints
..
rrect
()..
rrect
()..
rrect
()..
rrect
()..
rrect
()..
rrect
(
color:
color
),
);
});
// Regression test for https://github.com/flutter/flutter/issues/103566
testWidgets
(
'Drag gesture uses provided gesture settings'
,
(
WidgetTester
tester
)
async
{
double
value
=
0.5
;
bool
dragStarted
=
false
;
final
Key
sliderKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Material
(
child:
Center
(
child:
GestureDetector
(
behavior:
HitTestBehavior
.
deferToChild
,
onHorizontalDragStart:
(
DragStartDetails
details
)
{
dragStarted
=
true
;
},
child:
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
gestureSettings:
const
DeviceGestureSettings
(
touchSlop:
20
)),
child:
Slider
(
value:
value
,
key:
sliderKey
,
onChanged:
(
double
newValue
)
{
setState
(()
{
value
=
newValue
;
});
},
),
),
),
),
);
},
),
),
),
);
TestGesture
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
sliderKey
)));
await
tester
.
pump
(
kPressTimeout
);
// Less than configured touch slop, more than default touch slop
await
drag
.
moveBy
(
const
Offset
(
19.0
,
0
));
await
tester
.
pump
();
expect
(
value
,
0.5
);
expect
(
dragStarted
,
true
);
dragStarted
=
false
;
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
drag
=
await
tester
.
startGesture
(
tester
.
getCenter
(
find
.
byKey
(
sliderKey
)));
await
tester
.
pump
(
kPressTimeout
);
bool
sliderEnd
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
Material
(
child:
Center
(
child:
GestureDetector
(
behavior:
HitTestBehavior
.
deferToChild
,
onHorizontalDragStart:
(
DragStartDetails
details
)
{
dragStarted
=
true
;
},
child:
MediaQuery
(
data:
MediaQuery
.
of
(
context
).
copyWith
(
gestureSettings:
const
DeviceGestureSettings
(
touchSlop:
10
)),
child:
Slider
(
value:
value
,
key:
sliderKey
,
onChanged:
(
double
newValue
)
{
setState
(()
{
value
=
newValue
;
});
},
onChangeEnd:
(
double
endValue
)
{
sliderEnd
=
true
;
},
),
),
),
),
);
},
),
),
),
);
// More than touch slop.
await
drag
.
moveBy
(
const
Offset
(
12.0
,
0
));
await
drag
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
sliderEnd
,
true
);
expect
(
dragStarted
,
false
);
});
}
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