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
38fdf56c
Commit
38fdf56c
authored
Jul 26, 2019
by
brettfingo
Committed by
Anthony
Jul 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix slider preferred height (#36028)
[Material] Fix slider preferred height
parent
9c8badd1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletion
+63
-1
slider.dart
packages/flutter/lib/src/material/slider.dart
+1
-1
slider_test.dart
packages/flutter/test/material/slider_test.dart
+62
-0
No files found.
packages/flutter/lib/src/material/slider.dart
View file @
38fdf56c
...
...
@@ -698,7 +698,7 @@ class _RenderSlider extends RenderBox {
// other than the track shape. It is assumed that these shapes are vertically
// centered on the track.
double
get
_maxSliderPartWidth
=>
_sliderPartSizes
.
map
((
Size
size
)
=>
size
.
width
).
reduce
(
math
.
max
);
double
get
_maxSliderPartHeight
=>
_sliderPartSizes
.
map
((
Size
size
)
=>
size
.
width
).
reduce
(
math
.
max
);
double
get
_maxSliderPartHeight
=>
_sliderPartSizes
.
map
((
Size
size
)
=>
size
.
height
).
reduce
(
math
.
max
);
List
<
Size
>
get
_sliderPartSizes
=>
<
Size
>[
_sliderTheme
.
overlayShape
.
getPreferredSize
(
isInteractive
,
isDiscrete
),
_sliderTheme
.
thumbShape
.
getPreferredSize
(
isInteractive
,
isDiscrete
),
...
...
packages/flutter/test/material/slider_test.dart
View file @
38fdf56c
...
...
@@ -46,6 +46,28 @@ class LoggingThumbShape extends SliderComponentShape {
}
}
class
TallSliderTickMarkShape
extends
SliderTickMarkShape
{
@override
Size
getPreferredSize
({
SliderThemeData
sliderTheme
,
bool
isEnabled
})
{
return
const
Size
(
10.0
,
200.0
);
}
@override
void
paint
(
PaintingContext
context
,
Offset
offset
,
{
Offset
thumbCenter
,
RenderBox
parentBox
,
SliderThemeData
sliderTheme
,
Animation
<
double
>
enableAnimation
,
bool
isEnabled
,
TextDirection
textDirection
,
})
{
final
Paint
paint
=
Paint
()..
color
=
Colors
.
red
;
context
.
canvas
.
drawRect
(
Rect
.
fromLTWH
(
offset
.
dx
,
offset
.
dy
,
10.0
,
20.0
),
paint
);
}
}
void
main
(
)
{
testWidgets
(
'Slider can move when tapped (LTR)'
,
(
WidgetTester
tester
)
async
{
final
Key
sliderKey
=
UniqueKey
();
...
...
@@ -1485,4 +1507,44 @@ void main() {
await
gesture
.
moveBy
(
const
Offset
(
600.0
,
0.0
));
expect
(
value
,
1.0
);
});
testWidgets
(
'Slider respects height from theme'
,
(
WidgetTester
tester
)
async
{
final
Key
sliderKey
=
UniqueKey
();
double
value
=
0.0
;
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
final
SliderThemeData
sliderTheme
=
SliderTheme
.
of
(
context
).
copyWith
(
tickMarkShape:
TallSliderTickMarkShape
());
return
MediaQuery
(
data:
MediaQueryData
.
fromWindow
(
window
),
child:
Material
(
child:
Center
(
child:
IntrinsicHeight
(
child:
SliderTheme
(
data:
sliderTheme
,
child:
Slider
(
key:
sliderKey
,
value:
value
,
divisions:
4
,
onChanged:
(
double
newValue
)
{
setState
(()
{
value
=
newValue
;
});
},
),
),
),
),
),
);
},
),
),
);
final
RenderBox
renderObject
=
tester
.
renderObject
<
RenderBox
>(
find
.
byType
(
Slider
));
expect
(
renderObject
.
size
.
height
,
200
);
});
}
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