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
c26c2363
Unverified
Commit
c26c2363
authored
Aug 28, 2020
by
xubaolin
Committed by
GitHub
Aug 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slider paint incorrectly when the track shape is rectangular (#64534)
parent
f1a23574
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
4 deletions
+39
-4
slider_theme.dart
packages/flutter/lib/src/material/slider_theme.dart
+2
-4
slider_test.dart
packages/flutter/test/material/slider_test.dart
+37
-0
No files found.
packages/flutter/lib/src/material/slider_theme.dart
View file @
c26c2363
...
...
@@ -1560,12 +1560,10 @@ class RectangularSliderTrackShape extends SliderTrackShape with BaseSliderTrackS
isDiscrete:
isDiscrete
,
);
final
Size
thumbSize
=
sliderTheme
.
thumbShape
.
getPreferredSize
(
isEnabled
,
isDiscrete
);
final
Rect
leftTrackSegment
=
Rect
.
fromLTRB
(
trackRect
.
left
+
trackRect
.
height
/
2
,
trackRect
.
top
,
thumbCenter
.
dx
-
thumbSize
.
width
/
2
,
trackRect
.
bottom
);
final
Rect
leftTrackSegment
=
Rect
.
fromLTRB
(
trackRect
.
left
,
trackRect
.
top
,
thumbCenter
.
dx
,
trackRect
.
bottom
);
if
(!
leftTrackSegment
.
isEmpty
)
context
.
canvas
.
drawRect
(
leftTrackSegment
,
leftTrackPaint
);
final
Rect
rightTrackSegment
=
Rect
.
fromLTRB
(
thumbCenter
.
dx
+
thumbSize
.
width
/
2
,
trackRect
.
top
,
trackRect
.
right
,
trackRect
.
bottom
);
final
Rect
rightTrackSegment
=
Rect
.
fromLTRB
(
thumbCenter
.
dx
,
trackRect
.
top
,
trackRect
.
right
,
trackRect
.
bottom
);
if
(!
rightTrackSegment
.
isEmpty
)
context
.
canvas
.
drawRect
(
rightTrackSegment
,
rightTrackPaint
);
}
...
...
packages/flutter/test/material/slider_test.dart
View file @
c26c2363
...
...
@@ -2359,4 +2359,41 @@ void main() {
'inactiveColor: MaterialColor(primary value: Color(0xff9e9e9e))'
,
]);
});
testWidgets
(
'Slider paint correctly when the track shape is rectangular'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
theme:
ThemeData
(
sliderTheme:
const
SliderThemeData
(
trackShape:
RectangularSliderTrackShape
(),
)
),
home:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
),
child:
const
Material
(
child:
Center
(
child:
Slider
(
value:
0.5
,
onChanged:
null
,
),
),
),
),
),
),
);
// _RenderSlider is the last render object in the tree.
final
RenderObject
renderObject
=
tester
.
allRenderObjects
.
last
;
// The active track rect should start at 24.0 pixels,
// and there should not have a gap between active and inactive track.
expect
(
renderObject
,
paints
..
rect
(
rect:
const
Rect
.
fromLTRB
(
24.0
,
298.0
,
400.0
,
302.0
))
// active track Rect.
..
rect
(
rect:
const
Rect
.
fromLTRB
(
400.0
,
298.0
,
776.0
,
302.0
))
// inactive track Rect.
);
});
}
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