Unverified Commit 50706203 authored by Mohammed  CHAHBOUN's avatar Mohammed CHAHBOUN Committed by GitHub

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
parent 57dc071f
......@@ -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,
......
......@@ -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
......
......@@ -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;
......
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