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
b3434459
Unverified
Commit
b3434459
authored
May 26, 2020
by
Ayush Bherwani
Committed by
GitHub
May 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CheckboxListTile] exposes contentPadding property of ListTile. (#57868)
parent
9d58a870
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
1 deletion
+40
-1
checkbox_list_tile.dart
packages/flutter/lib/src/material/checkbox_list_tile.dart
+11
-1
checkbox_list_tile_test.dart
packages/flutter/test/material/checkbox_list_tile_test.dart
+29
-0
No files found.
packages/flutter/lib/src/material/checkbox_list_tile.dart
View file @
b3434459
...
...
@@ -20,7 +20,7 @@ import 'theme_data.dart';
/// The [value], [onChanged], [activeColor] and [checkColor] properties of this widget are
/// identical to the similarly-named properties on the [Checkbox] widget.
///
/// The [title], [subtitle], [isThreeLine],
and [dense
] properties are like
/// The [title], [subtitle], [isThreeLine],
[dense], and [contentPadding
] properties are like
/// those of the same name on [ListTile].
///
/// The [selected] property on this widget is similar to the [ListTile.selected]
...
...
@@ -267,6 +267,7 @@ class CheckboxListTile extends StatelessWidget {
this
.
selected
=
false
,
this
.
controlAffinity
=
ListTileControlAffinity
.
platform
,
this
.
autofocus
=
false
,
this
.
contentPadding
,
})
:
assert
(
value
!=
null
),
assert
(
isThreeLine
!=
null
),
assert
(!
isThreeLine
||
subtitle
!=
null
),
...
...
@@ -356,6 +357,14 @@ class CheckboxListTile extends StatelessWidget {
/// {@macro flutter.widgets.Focus.autofocus}
final
bool
autofocus
;
/// Defines insets surrounding the tile's contents.
///
/// This value will surround the [Checkbox], [title], [subtitle], and [secondary]
/// widgets in [CheckboxListTile].
///
/// When the value is null, the `contentPadding` is `EdgeInsets.symmetric(horizontal: 16.0)`.
final
EdgeInsetsGeometry
contentPadding
;
@override
Widget
build
(
BuildContext
context
)
{
final
Widget
control
=
Checkbox
(
...
...
@@ -392,6 +401,7 @@ class CheckboxListTile extends StatelessWidget {
onTap:
onChanged
!=
null
?
()
{
onChanged
(!
value
);
}
:
null
,
selected:
selected
,
autofocus:
autofocus
,
contentPadding:
contentPadding
,
),
),
);
...
...
packages/flutter/test/material/checkbox_list_tile_test.dart
View file @
b3434459
...
...
@@ -115,4 +115,33 @@ void main() {
expect
(
Focus
.
of
(
childKey
.
currentContext
,
nullOk:
true
).
hasPrimaryFocus
,
isFalse
);
});
testWidgets
(
'CheckoxListTile contentPadding test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
wrap
(
child:
const
Center
(
child:
CheckboxListTile
(
value:
false
,
onChanged:
null
,
title:
Text
(
'Title'
),
contentPadding:
EdgeInsets
.
fromLTRB
(
10
,
18
,
4
,
2
),
),
),
)
);
final
Rect
paddingRect
=
tester
.
getRect
(
find
.
byType
(
Padding
));
final
Rect
checkboxRect
=
tester
.
getRect
(
find
.
byType
(
Checkbox
));
final
Rect
titleRect
=
tester
.
getRect
(
find
.
text
(
'Title'
));
final
Rect
tallerWidget
=
checkboxRect
.
height
>
titleRect
.
height
?
checkboxRect
:
titleRect
;
// Check the offsets of CheckBox and title after padding is applied.
expect
(
paddingRect
.
right
,
checkboxRect
.
right
+
4
);
expect
(
paddingRect
.
left
,
titleRect
.
left
-
10
);
// Calculate the remaining height from the default ListTile height.
final
double
remainingHeight
=
56
-
tallerWidget
.
height
;
expect
(
paddingRect
.
top
,
tallerWidget
.
top
-
remainingHeight
/
2
-
18
);
expect
(
paddingRect
.
bottom
,
tallerWidget
.
bottom
+
remainingHeight
/
2
+
2
);
});
}
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