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
d40f4399
Unverified
Commit
d40f4399
authored
Jan 28, 2021
by
xubaolin
Committed by
GitHub
Jan 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a slider layout bug when the overlay size is smaller than the thumb size (#74880)
parent
29e604e2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
1 deletion
+42
-1
slider_theme.dart
packages/flutter/lib/src/material/slider_theme.dart
+1
-1
slider_theme_test.dart
packages/flutter/test/material/slider_theme_test.dart
+41
-0
No files found.
packages/flutter/lib/src/material/slider_theme.dart
View file @
d40f4399
...
...
@@ -1451,7 +1451,7 @@ abstract class BaseSliderTrackShape {
assert
(
overlayWidth
>=
0
);
assert
(
trackHeight
>=
0
);
final
double
trackLeft
=
offset
.
dx
+
overlayWidth
/
2
;
final
double
trackLeft
=
offset
.
dx
+
math
.
max
(
overlayWidth
/
2
,
thumbWidth
/
2
)
;
final
double
trackTop
=
offset
.
dy
+
(
parentBox
.
size
.
height
-
trackHeight
)
/
2
;
final
double
trackRight
=
trackLeft
+
parentBox
.
size
.
width
-
math
.
max
(
thumbWidth
,
overlayWidth
);
final
double
trackBottom
=
trackTop
+
trackHeight
;
...
...
packages/flutter/test/material/slider_theme_test.dart
View file @
d40f4399
...
...
@@ -852,6 +852,47 @@ void main() {
);
});
// Regression test for https://github.com/flutter/flutter/issues/74503
testWidgets
(
'The slider track layout correctly when the overlay size is smaller than the thumb size'
,
(
WidgetTester
tester
)
async
{
final
SliderThemeData
sliderTheme
=
ThemeData
().
sliderTheme
.
copyWith
(
overlayShape:
SliderComponentShape
.
noOverlay
,
);
await
tester
.
pumpWidget
(
_buildApp
(
sliderTheme
,
value:
0.5
));
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
)),
)!;
// The track rectangle begins at 10 pixels from the left of the screen and ends 10 pixels from the right
// (790 pixels from the left). The main check here it that the track itself should be centered on
// the 800 pixel-wide screen.
expect
(
material
,
paints
// active track RRect. Starts 10 pixels from left of screen.
..
rrect
(
rrect:
RRect
.
fromLTRBAndCorners
(
10.0
,
297.0
,
400.0
,
303.0
,
topLeft:
const
Radius
.
circular
(
3.0
),
bottomLeft:
const
Radius
.
circular
(
3.0
),
))
// inactive track RRect. Ends 10 pixels from right of screen.
..
rrect
(
rrect:
RRect
.
fromLTRBAndCorners
(
400.0
,
298.0
,
790.0
,
302.0
,
topRight:
const
Radius
.
circular
(
2.0
),
bottomRight:
const
Radius
.
circular
(
2.0
),
))
// The thumb.
..
circle
(
x:
400.0
,
y:
300.0
,
radius:
10.0
,
)
);
});
// Only the thumb, overlay, and tick mark have special shortcuts to provide
// no-op or empty shapes.
//
...
...
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