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
38df107b
Unverified
Commit
38df107b
authored
Jun 13, 2022
by
Mahesh Jamdade
Committed by
GitHub
Jun 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add enabled property to CheckboxlistTile (#102314)
parent
d31c250e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
checkbox_list_tile.dart
packages/flutter/lib/src/material/checkbox_list_tile.dart
+10
-2
checkbox_list_tile_test.dart
packages/flutter/test/material/checkbox_list_tile_test.dart
+41
-0
No files found.
packages/flutter/lib/src/material/checkbox_list_tile.dart
View file @
38df107b
...
...
@@ -127,6 +127,7 @@ class CheckboxListTile extends StatelessWidget {
required
this
.
onChanged
,
this
.
activeColor
,
this
.
checkColor
,
this
.
enabled
,
this
.
tileColor
,
this
.
title
,
this
.
subtitle
,
...
...
@@ -295,6 +296,13 @@ class CheckboxListTile extends StatelessWidget {
/// * [Feedback] for providing platform-specific feedback to certain actions.
final
bool
?
enableFeedback
;
/// Whether the CheckboxListTile is interactive.
///
/// If false, this list tile is styled with the disabled color from the
/// current [Theme] and the [ListTile.onTap] callback is
/// inoperative.
final
bool
?
enabled
;
void
_handleValueChange
()
{
assert
(
onChanged
!=
null
);
switch
(
value
)
{
...
...
@@ -314,7 +322,7 @@ class CheckboxListTile extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
final
Widget
control
=
Checkbox
(
value:
value
,
onChanged:
onChanged
,
onChanged:
enabled
??
true
?
onChanged
:
null
,
activeColor:
activeColor
,
checkColor:
checkColor
,
materialTapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
...
...
@@ -345,7 +353,7 @@ class CheckboxListTile extends StatelessWidget {
trailing:
trailing
,
isThreeLine:
isThreeLine
,
dense:
dense
,
enabled:
onChanged
!=
null
,
enabled:
enabled
??
onChanged
!=
null
,
onTap:
onChanged
!=
null
?
_handleValueChange
:
null
,
selected:
selected
,
autofocus:
autofocus
,
...
...
packages/flutter/test/material/checkbox_list_tile_test.dart
View file @
38df107b
...
...
@@ -421,6 +421,47 @@ void main() {
expect
(
tileNode
.
hasPrimaryFocus
,
isTrue
);
});
testWidgets
(
'CheckboxListTile can be disabled'
,
(
WidgetTester
tester
)
async
{
bool
?
value
=
false
;
bool
enabled
=
true
;
await
tester
.
pumpWidget
(
Material
(
child:
StatefulBuilder
(
builder:
(
BuildContext
context
,
StateSetter
setState
)
{
return
wrap
(
child:
CheckboxListTile
(
title:
const
Text
(
'Title'
),
enabled:
enabled
,
value:
value
,
onChanged:
(
bool
?
v
)
{
setState
(()
{
value
=
v
;
enabled
=
!
enabled
;
});
},
),
);
},
),
),
);
final
Finder
checkbox
=
find
.
byType
(
Checkbox
);
// verify initial values
expect
(
tester
.
widget
<
Checkbox
>(
checkbox
).
value
,
false
);
expect
(
enabled
,
true
);
// Tap the checkbox to disable CheckboxListTile
await
tester
.
tap
(
checkbox
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
widget
<
Checkbox
>(
checkbox
).
value
,
true
);
expect
(
enabled
,
false
);
await
tester
.
tap
(
checkbox
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
widget
<
Checkbox
>(
checkbox
).
value
,
true
);
});
group
(
'feedback'
,
()
{
late
FeedbackTester
feedback
;
...
...
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