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
e7a4e7c3
Unverified
Commit
e7a4e7c3
authored
Dec 10, 2018
by
Hans Muller
Committed by
GitHub
Dec 10, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Switch doc: disabled state (#24941)
parent
ab36f054
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
switch.dart
packages/flutter/lib/src/material/switch.dart
+17
-5
No files found.
packages/flutter/lib/src/material/switch.dart
View file @
e7a4e7c3
...
...
@@ -35,6 +35,11 @@ enum _SwitchType { material, adaptive }
/// that use a switch will listen for the [onChanged] callback and rebuild the
/// switch with a new [value] to update the visual appearance of the switch.
///
/// If the [onChanged] callback is null, then the switch will be disabled (it
/// will not respond to input). A disabled switch's thumb and track are rendered
/// in shades of grey by default. The default appearance of a disabled switch
/// can be overridden with [inactiveThumbColor] and [inactiveTrackColor].
///
/// Requires one of its ancestors to be a [Material] widget.
///
/// See also:
...
...
@@ -505,8 +510,7 @@ class _RenderSwitch extends RenderToggleable {
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
final
Canvas
canvas
=
context
.
canvas
;
final
bool
isActive
=
onChanged
!=
null
;
final
bool
isEnabled
=
onChanged
!=
null
;
final
double
currentValue
=
position
.
value
;
double
visualPosition
;
...
...
@@ -519,7 +523,17 @@ class _RenderSwitch extends RenderToggleable {
break
;
}
final
Color
trackColor
=
isActive
?
Color
.
lerp
(
inactiveTrackColor
,
activeTrackColor
,
currentValue
)
:
inactiveTrackColor
;
final
Color
trackColor
=
isEnabled
?
Color
.
lerp
(
inactiveTrackColor
,
activeTrackColor
,
currentValue
)
:
inactiveTrackColor
;
final
Color
thumbColor
=
isEnabled
?
Color
.
lerp
(
inactiveColor
,
activeColor
,
currentValue
)
:
inactiveColor
;
final
ImageProvider
thumbImage
=
isEnabled
?
(
currentValue
<
0.5
?
inactiveThumbImage
:
activeThumbImage
)
:
inactiveThumbImage
;
// Paint the track
final
Paint
paint
=
Paint
()
...
...
@@ -544,8 +558,6 @@ class _RenderSwitch extends RenderToggleable {
try
{
_isPainting
=
true
;
BoxPainter
thumbPainter
;
final
Color
thumbColor
=
isActive
?
Color
.
lerp
(
inactiveColor
,
activeColor
,
currentValue
)
:
inactiveColor
;
final
ImageProvider
thumbImage
=
isActive
?
(
currentValue
<
0.5
?
inactiveThumbImage
:
activeThumbImage
)
:
inactiveThumbImage
;
if
(
_cachedThumbPainter
==
null
||
thumbColor
!=
_cachedThumbColor
||
thumbImage
!=
_cachedThumbImage
)
{
_cachedThumbColor
=
thumbColor
;
_cachedThumbImage
=
thumbImage
;
...
...
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