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
f2c12d7e
Unverified
Commit
f2c12d7e
authored
May 18, 2020
by
Ayush Bherwani
Committed by
GitHub
May 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ExpansionTile.childrenPadding property (#57291)
parent
b70301fe
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
4 deletions
+69
-4
expansion_tile.dart
packages/flutter/lib/src/material/expansion_tile.dart
+12
-4
expansion_tile_test.dart
packages/flutter/test/material/expansion_tile_test.dart
+57
-0
No files found.
packages/flutter/lib/src/material/expansion_tile.dart
View file @
f2c12d7e
...
...
@@ -45,6 +45,7 @@ class ExpansionTile extends StatefulWidget {
this
.
tilePadding
,
this
.
expandedCrossAxisAlignment
,
this
.
expandedAlignment
,
this
.
childrenPadding
,
})
:
assert
(
initiallyExpanded
!=
null
),
assert
(
maintainState
!=
null
),
assert
(
...
...
@@ -138,6 +139,11 @@ class ExpansionTile extends StatefulWidget {
/// When the value is null, the value of `expandedCrossAxisAlignment` is [CrossAxisAlignment.center].
final
CrossAxisAlignment
expandedCrossAxisAlignment
;
/// Specifies padding for [children].
///
/// When the value is null, the value of `childrenPadding` is [EdgeInsets.zero].
final
EdgeInsetsGeometry
childrenPadding
;
@override
_ExpansionTileState
createState
()
=>
_ExpansionTileState
();
}
...
...
@@ -266,10 +272,13 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
final
Widget
result
=
Offstage
(
child:
TickerMode
(
child:
Padding
(
padding:
widget
.
childrenPadding
??
EdgeInsets
.
zero
,
child:
Column
(
crossAxisAlignment:
widget
.
expandedCrossAxisAlignment
??
CrossAxisAlignment
.
center
,
children:
widget
.
children
,
),
),
enabled:
!
closed
,
),
offstage:
closed
...
...
@@ -280,6 +289,5 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
builder:
_buildChildren
,
child:
shouldRemoveChildren
?
null
:
result
,
);
}
}
packages/flutter/test/material/expansion_tile_test.dart
View file @
f2c12d7e
...
...
@@ -424,4 +424,61 @@ void main() {
});
testWidgets
(
'childrenPadding default value'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
ExpansionTile
(
title:
const
Text
(
'title'
),
children:
<
Widget
>[
Container
(
height:
100
,
width:
100
),
],
),
),
),
));
await
tester
.
tap
(
find
.
text
(
'title'
));
await
tester
.
pumpAndSettle
();
final
Rect
columnRect
=
tester
.
getRect
(
find
.
byType
(
Column
).
last
);
final
Rect
paddingRect
=
tester
.
getRect
(
find
.
byType
(
Padding
).
last
);
// By default, the value of childrenPadding is EdgeInsets.zero, hence offset
// of all the edges from x-axis and y-axis should be equal for Padding and Column.
expect
(
columnRect
.
top
,
paddingRect
.
top
);
expect
(
columnRect
.
left
,
paddingRect
.
left
);
expect
(
columnRect
.
right
,
paddingRect
.
right
);
expect
(
columnRect
.
bottom
,
paddingRect
.
bottom
);
});
testWidgets
(
'ExpansionTile childrenPadding test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
ExpansionTile
(
title:
const
Text
(
'title'
),
childrenPadding:
const
EdgeInsets
.
fromLTRB
(
10
,
8
,
12
,
4
),
children:
<
Widget
>[
Container
(
height:
100
,
width:
100
),
],
),
),
),
));
await
tester
.
tap
(
find
.
text
(
'title'
));
await
tester
.
pumpAndSettle
();
final
Rect
columnRect
=
tester
.
getRect
(
find
.
byType
(
Column
).
last
);
final
Rect
paddingRect
=
tester
.
getRect
(
find
.
byType
(
Padding
).
last
);
// Check the offset of all the edges from x-axis and y-axis after childrenPadding
// is applied.
expect
(
columnRect
.
left
,
paddingRect
.
left
+
10
);
expect
(
columnRect
.
top
,
paddingRect
.
top
+
8
);
expect
(
columnRect
.
right
,
paddingRect
.
right
-
12
);
expect
(
columnRect
.
bottom
,
paddingRect
.
bottom
-
4
);
});
}
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