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
d3bc2bbc
Unverified
Commit
d3bc2bbc
authored
Jun 16, 2022
by
xubaolin
Committed by
GitHub
Jun 16, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] fix RangeSlider regression due to touch slop changes (#106094)
parent
d88212c8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
122 additions
and
4 deletions
+122
-4
range_slider.dart
packages/flutter/lib/src/material/range_slider.dart
+14
-3
range_slider_test.dart
packages/flutter/test/material/range_slider_test.dart
+108
-1
No files found.
packages/flutter/lib/src/material/range_slider.dart
View file @
d3bc2bbc
...
@@ -704,6 +704,7 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
...
@@ -704,6 +704,7 @@ 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
,
gestureSettings:
MediaQuery
.
of
(
context
).
gestureSettings
,
);
);
}
}
...
@@ -724,7 +725,8 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
...
@@ -724,7 +725,8 @@ class _RangeSliderRenderObjectWidget extends LeafRenderObjectWidget {
..
onChangeEnd
=
onChangeEnd
..
onChangeEnd
=
onChangeEnd
..
textDirection
=
Directionality
.
of
(
context
)
..
textDirection
=
Directionality
.
of
(
context
)
..
semanticFormatterCallback
=
semanticFormatterCallback
..
semanticFormatterCallback
=
semanticFormatterCallback
..
platform
=
Theme
.
of
(
context
).
platform
;
..
platform
=
Theme
.
of
(
context
).
platform
..
gestureSettings
=
MediaQuery
.
of
(
context
).
gestureSettings
;
}
}
}
}
...
@@ -744,6 +746,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
...
@@ -744,6 +746,7 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
required
this
.
onChangeEnd
,
required
this
.
onChangeEnd
,
required
_RangeSliderState
state
,
required
_RangeSliderState
state
,
required
TextDirection
textDirection
,
required
TextDirection
textDirection
,
required
DeviceGestureSettings
gestureSettings
,
})
:
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
),
...
@@ -768,12 +771,14 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
...
@@ -768,12 +771,14 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
..
onStart
=
_handleDragStart
..
onStart
=
_handleDragStart
..
onUpdate
=
_handleDragUpdate
..
onUpdate
=
_handleDragUpdate
..
onEnd
=
_handleDragEnd
..
onEnd
=
_handleDragEnd
..
onCancel
=
_handleDragCancel
;
..
onCancel
=
_handleDragCancel
..
gestureSettings
=
gestureSettings
;
_tap
=
TapGestureRecognizer
()
_tap
=
TapGestureRecognizer
()
..
team
=
team
..
team
=
team
..
onTapDown
=
_handleTapDown
..
onTapDown
=
_handleTapDown
..
onTapUp
=
_handleTapUp
..
onTapUp
=
_handleTapUp
..
onTapCancel
=
_handleTapCancel
;
..
onTapCancel
=
_handleTapCancel
..
gestureSettings
=
gestureSettings
;
_overlayAnimation
=
CurvedAnimation
(
_overlayAnimation
=
CurvedAnimation
(
parent:
_state
.
overlayController
,
parent:
_state
.
overlayController
,
curve:
Curves
.
fastOutSlowIn
,
curve:
Curves
.
fastOutSlowIn
,
...
@@ -882,6 +887,12 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
...
@@ -882,6 +887,12 @@ class _RenderRangeSlider extends RenderBox with RelayoutWhenSystemFontsChangeMix
markNeedsSemanticsUpdate
();
markNeedsSemanticsUpdate
();
}
}
DeviceGestureSettings
?
get
gestureSettings
=>
_drag
.
gestureSettings
;
set
gestureSettings
(
DeviceGestureSettings
?
gestureSettings
)
{
_drag
.
gestureSettings
=
gestureSettings
;
_tap
.
gestureSettings
=
gestureSettings
;
}
SemanticFormatterCallback
?
_semanticFormatterCallback
;
SemanticFormatterCallback
?
_semanticFormatterCallback
;
SemanticFormatterCallback
?
get
semanticFormatterCallback
=>
_semanticFormatterCallback
;
SemanticFormatterCallback
?
get
semanticFormatterCallback
=>
_semanticFormatterCallback
;
set
semanticFormatterCallback
(
SemanticFormatterCallback
?
value
)
{
set
semanticFormatterCallback
(
SemanticFormatterCallback
?
value
)
{
...
...
packages/flutter/test/material/range_slider_test.dart
View file @
d3bc2bbc
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/src/physics/utils.dart'
show
nearEqual
;
import
'package:flutter/src/physics/utils.dart'
show
nearEqual
;
...
@@ -12,6 +12,113 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -12,6 +12,113 @@ import 'package:flutter_test/flutter_test.dart';
import
'../rendering/mock_canvas.dart'
;
import
'../rendering/mock_canvas.dart'
;
void
main
(
)
{
void
main
(
)
{
// Regression test for https://github.com/flutter/flutter/issues/105833
testWidgets
(
'Drag gesture uses provided gesture settings'
,
(
WidgetTester
tester
)
async
{
RangeValues
values
=
const
RangeValues
(
0.1
,
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:
RangeSlider
(
key:
sliderKey
,
values:
values
,
onChanged:
(
RangeValues
newValues
)
{
setState
(()
{
values
=
newValues
;
});
},
),
),
),
),
);
},
),
),
),
);
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
(
values
,
const
RangeValues
(
0.1
,
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:
RangeSlider
(
key:
sliderKey
,
values:
values
,
onChanged:
(
RangeValues
newValues
)
{
setState
(()
{
values
=
newValues
;
});
},
onChangeEnd:
(
RangeValues
newValues
)
{
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
);
});
testWidgets
(
'Range Slider can move when tapped (continuous LTR)'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Range Slider can move when tapped (continuous LTR)'
,
(
WidgetTester
tester
)
async
{
RangeValues
values
=
const
RangeValues
(
0.3
,
0.7
);
RangeValues
values
=
const
RangeValues
(
0.3
,
0.7
);
...
...
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