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
fb664702
Unverified
Commit
fb664702
authored
Jun 11, 2021
by
nohli
Committed by
GitHub
Jun 11, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add slider adaptive cupertino thumb color (#81647)
parent
016ad85d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
113 additions
and
1 deletion
+113
-1
slider.dart
packages/flutter/lib/src/material/slider.dart
+12
-1
slider_test.dart
packages/flutter/test/material/slider_test.dart
+101
-0
No files found.
packages/flutter/lib/src/material/slider.dart
View file @
fb664702
...
...
@@ -153,6 +153,7 @@ class Slider extends StatefulWidget {
this
.
label
,
this
.
activeColor
,
this
.
inactiveColor
,
this
.
thumbColor
,
this
.
mouseCursor
,
this
.
semanticFormatterCallback
,
this
.
focusNode
,
...
...
@@ -190,6 +191,7 @@ class Slider extends StatefulWidget {
this
.
mouseCursor
,
this
.
activeColor
,
this
.
inactiveColor
,
this
.
thumbColor
,
this
.
semanticFormatterCallback
,
this
.
focusNode
,
this
.
autofocus
=
false
,
...
...
@@ -382,6 +384,14 @@ class Slider extends StatefulWidget {
/// Ignored if this slider is created with [Slider.adaptive].
final
Color
?
inactiveColor
;
/// The color of the thumb.
///
/// If this color is null:
/// * [Slider] will use [activeColor].
/// * [CupertinoSlider] will have a white thumb
/// (like the native default iOS slider).
final
Color
?
thumbColor
;
/// The cursor for a mouse pointer when it enters or is hovering over the
/// widget.
///
...
...
@@ -679,7 +689,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
inactiveTickMarkColor:
widget
.
activeColor
??
sliderTheme
.
inactiveTickMarkColor
??
theme
.
colorScheme
.
primary
.
withOpacity
(
0.54
),
disabledActiveTickMarkColor:
sliderTheme
.
disabledActiveTickMarkColor
??
theme
.
colorScheme
.
onPrimary
.
withOpacity
(
0.12
),
disabledInactiveTickMarkColor:
sliderTheme
.
disabledInactiveTickMarkColor
??
theme
.
colorScheme
.
onSurface
.
withOpacity
(
0.12
),
thumbColor:
widget
.
activeColor
??
sliderTheme
.
thumbColor
??
theme
.
colorScheme
.
primary
,
thumbColor:
widget
.
thumbColor
??
widget
.
activeColor
??
sliderTheme
.
thumbColor
??
theme
.
colorScheme
.
primary
,
disabledThumbColor:
sliderTheme
.
disabledThumbColor
??
Color
.
alphaBlend
(
theme
.
colorScheme
.
onSurface
.
withOpacity
(.
38
),
theme
.
colorScheme
.
surface
),
overlayColor:
widget
.
activeColor
?.
withOpacity
(
0.12
)
??
sliderTheme
.
overlayColor
??
theme
.
colorScheme
.
primary
.
withOpacity
(
0.12
),
valueIndicatorColor:
valueIndicatorColor
,
...
...
@@ -757,6 +767,7 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
max:
widget
.
max
,
divisions:
widget
.
divisions
,
activeColor:
widget
.
activeColor
,
thumbColor:
widget
.
thumbColor
??
CupertinoColors
.
white
,
),
);
}
...
...
packages/flutter/test/material/slider_test.dart
View file @
fb664702
...
...
@@ -2513,4 +2513,105 @@ void main() {
// 24.0 is the default margin, (800.0 - 24.0 - 24.0) is the slider's width.
expect
(
nearEqual
(
activeTrackRRect
.
right
,
(
800.0
-
24.0
-
24.0
)
*
(
5
/
15
)
+
24.0
,
0.01
),
true
);
});
testWidgets
(
'Slider paints thumbColor'
,
(
WidgetTester
tester
)
async
{
const
Color
color
=
Color
(
0xffffc107
);
final
Widget
sliderAdaptive
=
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Material
(
child:
Slider
(
value:
0
,
onChanged:
(
double
newValue
)
{},
thumbColor:
color
,
),
),
);
await
tester
.
pumpWidget
(
sliderAdaptive
);
await
tester
.
pumpAndSettle
();
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
)))!;
expect
(
material
,
paints
..
circle
(
color:
color
));
});
testWidgets
(
'Slider.adaptive paints thumbColor on Android'
,
(
WidgetTester
tester
)
async
{
const
Color
color
=
Color
(
0xffffc107
);
final
Widget
sliderAdaptive
=
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
android
),
home:
Material
(
child:
Slider
.
adaptive
(
value:
0
,
onChanged:
(
double
newValue
)
{},
thumbColor:
color
,
),
),
);
await
tester
.
pumpWidget
(
sliderAdaptive
);
await
tester
.
pumpAndSettle
();
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
Slider
)))!;
expect
(
material
,
paints
..
circle
(
color:
color
));
});
testWidgets
(
'If thumbColor is null, it defaults to CupertinoColors.white'
,
(
WidgetTester
tester
)
async
{
final
Widget
sliderAdaptive
=
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Material
(
child:
Slider
.
adaptive
(
value:
0
,
onChanged:
(
double
newValue
)
{},
),
),
);
await
tester
.
pumpWidget
(
sliderAdaptive
);
await
tester
.
pumpAndSettle
();
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
CupertinoSlider
)))!;
expect
(
material
,
paints
..
rrect
()
..
rrect
()
..
rrect
()
..
rrect
()
..
rrect
()
..
rrect
(
color:
CupertinoColors
.
white
),
);
});
testWidgets
(
'Slider.adaptive passes thumbColor to CupertinoSlider'
,
(
WidgetTester
tester
)
async
{
const
Color
color
=
Color
(
0xffffc107
);
final
Widget
sliderAdaptive
=
MaterialApp
(
theme:
ThemeData
(
platform:
TargetPlatform
.
iOS
),
home:
Material
(
child:
Slider
.
adaptive
(
value:
0
,
onChanged:
(
double
newValue
)
{},
thumbColor:
color
,
),
),
);
await
tester
.
pumpWidget
(
sliderAdaptive
);
await
tester
.
pumpAndSettle
();
final
MaterialInkController
material
=
Material
.
of
(
tester
.
element
(
find
.
byType
(
CupertinoSlider
)))!;
expect
(
material
,
paints
..
rrect
()..
rrect
()..
rrect
()..
rrect
()..
rrect
()..
rrect
(
color:
color
),
);
});
}
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