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
1f132e90
Unverified
Commit
1f132e90
authored
Apr 23, 2020
by
Ayush Bherwani
Committed by
GitHub
Apr 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ExpansionTile] Adds tilePadding property to ExpansionTile (#55221)
* Adds tilePadding property to ExpansionTile
parent
2ae0e5a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
expansion_tile.dart
packages/flutter/lib/src/material/expansion_tile.dart
+11
-0
expansion_tile_test.dart
packages/flutter/test/material/expansion_tile_test.dart
+27
-0
No files found.
packages/flutter/lib/src/material/expansion_tile.dart
View file @
1f132e90
...
...
@@ -41,6 +41,7 @@ class ExpansionTile extends StatefulWidget {
this
.
children
=
const
<
Widget
>[],
this
.
trailing
,
this
.
initiallyExpanded
=
false
,
this
.
tilePadding
,
})
:
assert
(
initiallyExpanded
!=
null
),
super
(
key:
key
);
...
...
@@ -80,6 +81,15 @@ class ExpansionTile extends StatefulWidget {
/// Specifies if the list tile is initially expanded (true) or collapsed (false, the default).
final
bool
initiallyExpanded
;
/// Specifies padding for the [ListTile].
///
/// Analogous to [ListTile.contentPadding], this property defines the insets for
/// the [leading], [title], [subtitle] and [trailing] widgets. It does not inset
/// the expanded [children] widgets.
///
/// When the value is null, the tile's padding is `EdgeInsets.symmetric(horizontal: 16.0)`.
final
EdgeInsetsGeometry
tilePadding
;
@override
_ExpansionTileState
createState
()
=>
_ExpansionTileState
();
}
...
...
@@ -165,6 +175,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
textColor:
_headerColor
.
value
,
child:
ListTile
(
onTap:
_handleTap
,
contentPadding:
widget
.
tilePadding
,
leading:
widget
.
leading
,
title:
widget
.
title
,
subtitle:
widget
.
subtitle
,
...
...
packages/flutter/test/material/expansion_tile_test.dart
View file @
1f132e90
...
...
@@ -229,4 +229,31 @@ void main() {
expect
(
find
.
text
(
'Subtitle'
),
findsOneWidget
);
});
testWidgets
(
'ExpansionTile padding test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Material
(
child:
Center
(
child:
ExpansionTile
(
title:
Text
(
'Hello'
),
tilePadding:
EdgeInsets
.
fromLTRB
(
8
,
12
,
4
,
10
),
),
),
),
));
final
Rect
titleRect
=
tester
.
getRect
(
find
.
text
(
'Hello'
));
final
Rect
trailingRect
=
tester
.
getRect
(
find
.
byIcon
(
Icons
.
expand_more
));
final
Rect
listTileRect
=
tester
.
getRect
(
find
.
byType
(
ListTile
));
final
Rect
tallerWidget
=
titleRect
.
height
>
trailingRect
.
height
?
titleRect
:
trailingRect
;
// Check the positions of title and trailing Widgets, after padding is applied.
expect
(
listTileRect
.
left
,
titleRect
.
left
-
8
);
expect
(
listTileRect
.
right
,
trailingRect
.
right
+
4
);
// Calculate the remaining height of ListTile from the default height.
final
double
remainingHeight
=
56
-
tallerWidget
.
height
;
expect
(
listTileRect
.
top
,
tallerWidget
.
top
-
remainingHeight
/
2
-
12
);
expect
(
listTileRect
.
bottom
,
tallerWidget
.
bottom
+
remainingHeight
/
2
+
10
);
});
}
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