Unverified Commit 4019956f authored by Ayush Bherwani's avatar Ayush Bherwani Committed by GitHub

[ExpansionTile] adds collapsedBackgroundColor property (#69575)

parent d618b810
......@@ -46,6 +46,7 @@ class ExpansionTile extends StatefulWidget {
this.expandedCrossAxisAlignment,
this.expandedAlignment,
this.childrenPadding,
this.collapsedBackgroundColor,
}) : assert(initiallyExpanded != null),
assert(maintainState != null),
assert(
......@@ -85,6 +86,9 @@ class ExpansionTile extends StatefulWidget {
/// The color to display behind the sublist when expanded.
final Color? backgroundColor;
/// When not null, defines the background color of tile when the sublist is collapsed.
final Color? collapsedBackgroundColor;
/// A widget to display instead of a rotating arrow icon.
final Widget? trailing;
......@@ -261,7 +265,9 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
_iconColorTween
..begin = theme.unselectedWidgetColor
..end = theme.accentColor;
_backgroundColorTween.end = widget.backgroundColor;
_backgroundColorTween
..begin = widget.collapsedBackgroundColor
..end = widget.backgroundColor;
super.didChangeDependencies();
}
......
......@@ -481,4 +481,40 @@ void main() {
expect(columnRect.bottom, paddingRect.bottom - 4);
});
testWidgets('ExpansionTile.collapsedBackgroundColor', (WidgetTester tester) async {
const Key expansionTileKey = Key('expansionTileKey');
const Color backgroundColor = Colors.red;
const Color collapsedBackgroundColor = Colors.brown;
await tester.pumpWidget(const MaterialApp(
home: Material(
child: ExpansionTile(
key: expansionTileKey,
title: Text('Title'),
backgroundColor: backgroundColor,
collapsedBackgroundColor: collapsedBackgroundColor,
children: <Widget>[
SizedBox(height: 100, width: 100),
],
),
),
));
BoxDecoration boxDecoration = tester.firstWidget<Container>(find.descendant(
of: find.byKey(expansionTileKey),
matching: find.byType(Container),
)).decoration! as BoxDecoration;
expect(boxDecoration.color, collapsedBackgroundColor);
await tester.tap(find.text('Title'));
await tester.pumpAndSettle();
boxDecoration = tester.firstWidget<Container>(find.descendant(
of: find.byKey(expansionTileKey),
matching: find.byType(Container),
)).decoration! as BoxDecoration;
expect(boxDecoration.color, backgroundColor);
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment