diff --git a/packages/flutter/lib/src/material/expand_icon.dart b/packages/flutter/lib/src/material/expand_icon.dart index ba20dcc5df267..fcf1f8799042c 100644 --- a/packages/flutter/lib/src/material/expand_icon.dart +++ b/packages/flutter/lib/src/material/expand_icon.dart @@ -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, diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 8195653e8c28d..6e64eeb733582 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -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 createState() => _ExpansionPanelListState(); } @@ -356,6 +361,7 @@ class _ExpansionPanelListState extends State { 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 diff --git a/packages/flutter/test/material/expansion_panel_test.dart b/packages/flutter/test/material/expansion_panel_test.dart index cea8f6a88c5ae..d6cdc27a4639f 100644 --- a/packages/flutter/test/material/expansion_panel_test.dart +++ b/packages/flutter/test/material/expansion_panel_test.dart @@ -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( + 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( + 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;