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
f3562c6f
Unverified
Commit
f3562c6f
authored
Oct 23, 2020
by
Yash Johri
Committed by
GitHub
Oct 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SwitchListTile and CheckboxListTile] Adds selectedTileColor property (#68358)
parent
0c63d63b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
0 deletions
+54
-0
checkbox_list_tile.dart
packages/flutter/lib/src/material/checkbox_list_tile.dart
+5
-0
switch_list_tile.dart
packages/flutter/lib/src/material/switch_list_tile.dart
+6
-0
checkbox_list_tile_test.dart
packages/flutter/test/material/checkbox_list_tile_test.dart
+21
-0
switch_list_tile_test.dart
packages/flutter/test/material/switch_list_tile_test.dart
+22
-0
No files found.
packages/flutter/lib/src/material/checkbox_list_tile.dart
View file @
f3562c6f
...
...
@@ -274,6 +274,7 @@ class CheckboxListTile extends StatelessWidget {
this
.
contentPadding
,
this
.
tristate
=
false
,
this
.
shape
,
this
.
selectedTileColor
,
})
:
assert
(
tristate
!=
null
),
assert
(
tristate
||
value
!=
null
),
assert
(
isThreeLine
!=
null
),
...
...
@@ -388,6 +389,9 @@ class CheckboxListTile extends StatelessWidget {
/// {@macro flutter.material.ListTile.shape}
final
ShapeBorder
?
shape
;
/// If non-null, defines the background color when [CheckboxListTile.selected] is true.
final
Color
?
selectedTileColor
;
void
_handleValueChange
()
{
assert
(
onChanged
!=
null
);
switch
(
value
)
{
...
...
@@ -442,6 +446,7 @@ class CheckboxListTile extends StatelessWidget {
autofocus:
autofocus
,
contentPadding:
contentPadding
,
shape:
shape
,
selectedTileColor:
selectedTileColor
,
tileColor:
tileColor
,
),
),
...
...
packages/flutter/lib/src/material/switch_list_tile.dart
View file @
f3562c6f
...
...
@@ -275,6 +275,7 @@ class SwitchListTile extends StatelessWidget {
this
.
autofocus
=
false
,
this
.
controlAffinity
=
ListTileControlAffinity
.
platform
,
this
.
shape
,
this
.
selectedTileColor
,
})
:
_switchListTileType
=
_SwitchListTileType
.
material
,
assert
(
value
!=
null
),
assert
(
isThreeLine
!=
null
),
...
...
@@ -312,6 +313,7 @@ class SwitchListTile extends StatelessWidget {
this
.
autofocus
=
false
,
this
.
controlAffinity
=
ListTileControlAffinity
.
platform
,
this
.
shape
,
this
.
selectedTileColor
,
})
:
_switchListTileType
=
_SwitchListTileType
.
adaptive
,
assert
(
value
!=
null
),
assert
(
isThreeLine
!=
null
),
...
...
@@ -445,6 +447,9 @@ class SwitchListTile extends StatelessWidget {
/// {@macro flutter.material.ListTile.shape}
final
ShapeBorder
?
shape
;
/// If non-null, defines the background color when [SwitchListTile.selected] is true.
final
Color
?
selectedTileColor
;
@override
Widget
build
(
BuildContext
context
)
{
final
Widget
control
;
...
...
@@ -506,6 +511,7 @@ class SwitchListTile extends StatelessWidget {
enabled:
onChanged
!=
null
,
onTap:
onChanged
!=
null
?
()
{
onChanged
!(!
value
);
}
:
null
,
selected:
selected
,
selectedTileColor:
selectedTileColor
,
autofocus:
autofocus
,
shape:
shape
,
tileColor:
tileColor
,
...
...
packages/flutter/test/material/checkbox_list_tile_test.dart
View file @
f3562c6f
...
...
@@ -259,4 +259,25 @@ void main() {
final
ColoredBox
coloredBox
=
tester
.
firstWidget
(
find
.
byType
(
ColoredBox
));
expect
(
coloredBox
.
color
,
equals
(
tileColor
));
});
testWidgets
(
'CheckboxListTile respects selectedTileColor'
,
(
WidgetTester
tester
)
async
{
const
Color
selectedTileColor
=
Colors
.
black
;
await
tester
.
pumpWidget
(
wrap
(
child:
const
Center
(
child:
CheckboxListTile
(
value:
false
,
onChanged:
null
,
title:
Text
(
'Title'
),
selected:
true
,
selectedTileColor:
selectedTileColor
,
),
),
),
);
final
ColoredBox
coloredBox
=
tester
.
firstWidget
(
find
.
byType
(
ColoredBox
));
expect
(
coloredBox
.
color
,
equals
(
selectedTileColor
));
});
}
packages/flutter/test/material/switch_list_tile_test.dart
View file @
f3562c6f
...
...
@@ -377,4 +377,26 @@ void main() {
final
ColoredBox
coloredBox
=
tester
.
firstWidget
(
find
.
byType
(
ColoredBox
));
expect
(
coloredBox
.
color
,
tileColor
);
});
testWidgets
(
'SwitchListTile respects selectedTileColor'
,
(
WidgetTester
tester
)
async
{
const
Color
selectedTileColor
=
Colors
.
black
;
await
tester
.
pumpWidget
(
wrap
(
child:
const
Center
(
child:
SwitchListTile
(
value:
false
,
onChanged:
null
,
title:
Text
(
'Title'
),
selected:
true
,
selectedTileColor:
selectedTileColor
,
),
),
),
);
final
ColoredBox
coloredBox
=
tester
.
firstWidget
(
find
.
byType
(
ColoredBox
));
expect
(
coloredBox
.
color
,
equals
(
selectedTileColor
));
});
}
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