Added expandIconColor property on ExpansionPanelList Widget (#115950)

* Create expanIconColor doc template

* Add expandIconColor property to ExpansionPanelList

* Added tests for expandIconColor on ExpansionPanelList & radio

* Removed trailing spaces
This commit is contained in:
Mohammed CHAHBOUN 2023-01-06 01:13:18 +01:00 committed by GitHub
parent 57dc071f79
commit 507062032f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 1 deletions

View File

@ -66,7 +66,7 @@ class ExpandIcon extends StatefulWidget {
/// This property must not be null. It defaults to 8.0 padding on all sides.
final EdgeInsetsGeometry padding;
/// {@template flutter.material.ExpandIcon.color}
/// The color of the icon.
///
/// Defaults to [Colors.black54] when the theme's
@ -74,6 +74,7 @@ class ExpandIcon extends StatefulWidget {
/// [Colors.white60] when it is [Brightness.dark]. This adheres to the
/// Material Design specifications for [icons](https://material.io/design/iconography/system-icons.html#color)
/// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application)
/// {@endtemplate}
final Color? color;
/// The color of the icon when it is disabled,

View File

@ -168,6 +168,7 @@ class ExpansionPanelList extends StatefulWidget {
this.expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
this.dividerColor,
this.elevation = 2,
this.expandIconColor,
}) : assert(children != null),
assert(animationDuration != null),
_allowOnlyOnePanelOpen = false,
@ -195,6 +196,7 @@ class ExpansionPanelList extends StatefulWidget {
this.expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
this.dividerColor,
this.elevation = 2,
this.expandIconColor,
}) : assert(children != null),
assert(animationDuration != null),
_allowOnlyOnePanelOpen = true;
@ -249,6 +251,9 @@ class ExpansionPanelList extends StatefulWidget {
/// By default, the value of elevation is 2.
final double elevation;
/// {@macro flutter.material.ExpandIcon.color}
final Color? expandIconColor;
@override
State<StatefulWidget> createState() => _ExpansionPanelListState();
}
@ -356,6 +361,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
Widget expandIconContainer = Container(
margin: const EdgeInsetsDirectional.only(end: 8.0),
child: ExpandIcon(
color: widget.expandIconColor,
isExpanded: _isChildExpanded(index),
padding: const EdgeInsets.all(16.0),
onPressed: !child.canTapOnHeader

View File

@ -1390,6 +1390,55 @@ void main() {
expect(boxDecoration.border!.top.color, dividerColor);
});
testWidgets('ExpansionPanelList respects expandIconColor', (WidgetTester tester) async {
const Color expandIconColor = Colors.blue;
await tester.pumpWidget(MaterialApp(
home: SingleChildScrollView(
child: ExpansionPanelList(
expandIconColor: expandIconColor,
children: <ExpansionPanel>[
ExpansionPanel(
canTapOnHeader: true,
body: const SizedBox.shrink(),
headerBuilder: (BuildContext context, bool isExpanded) {
return const SizedBox.shrink();
}
)
],
),
),
));
final ExpandIcon expandIcon = tester.widget(find.byType(ExpandIcon));
expect(expandIcon.color, expandIconColor);
});
testWidgets('ExpansionPanelList.radio respects expandIconColor', (WidgetTester tester) async {
const Color expandIconColor = Colors.blue;
await tester.pumpWidget(MaterialApp(
home: SingleChildScrollView(
child: ExpansionPanelList.radio(
expandIconColor: expandIconColor,
children: <ExpansionPanelRadio>[
ExpansionPanelRadio(
canTapOnHeader: true,
body: const SizedBox.shrink(),
headerBuilder: (BuildContext context, bool isExpanded) {
return const SizedBox.shrink();
},
value: true
)
],
),
),
));
final ExpandIcon expandIcon = tester.widget(find.byType(ExpandIcon));
expect(expandIcon.color, expandIconColor);
});
testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async {
const double elevation = 8;