mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
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:
parent
57dc071f79
commit
507062032f
@ -66,7 +66,7 @@ class ExpandIcon extends StatefulWidget {
|
|||||||
/// This property must not be null. It defaults to 8.0 padding on all sides.
|
/// This property must not be null. It defaults to 8.0 padding on all sides.
|
||||||
final EdgeInsetsGeometry padding;
|
final EdgeInsetsGeometry padding;
|
||||||
|
|
||||||
|
/// {@template flutter.material.ExpandIcon.color}
|
||||||
/// The color of the icon.
|
/// The color of the icon.
|
||||||
///
|
///
|
||||||
/// Defaults to [Colors.black54] when the theme's
|
/// 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
|
/// [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)
|
/// 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)
|
/// and for [dark theme](https://material.io/design/color/dark-theme.html#ui-application)
|
||||||
|
/// {@endtemplate}
|
||||||
final Color? color;
|
final Color? color;
|
||||||
|
|
||||||
/// The color of the icon when it is disabled,
|
/// The color of the icon when it is disabled,
|
||||||
|
@ -168,6 +168,7 @@ class ExpansionPanelList extends StatefulWidget {
|
|||||||
this.expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
|
this.expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
|
||||||
this.dividerColor,
|
this.dividerColor,
|
||||||
this.elevation = 2,
|
this.elevation = 2,
|
||||||
|
this.expandIconColor,
|
||||||
}) : assert(children != null),
|
}) : assert(children != null),
|
||||||
assert(animationDuration != null),
|
assert(animationDuration != null),
|
||||||
_allowOnlyOnePanelOpen = false,
|
_allowOnlyOnePanelOpen = false,
|
||||||
@ -195,6 +196,7 @@ class ExpansionPanelList extends StatefulWidget {
|
|||||||
this.expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
|
this.expandedHeaderPadding = _kPanelHeaderExpandedDefaultPadding,
|
||||||
this.dividerColor,
|
this.dividerColor,
|
||||||
this.elevation = 2,
|
this.elevation = 2,
|
||||||
|
this.expandIconColor,
|
||||||
}) : assert(children != null),
|
}) : assert(children != null),
|
||||||
assert(animationDuration != null),
|
assert(animationDuration != null),
|
||||||
_allowOnlyOnePanelOpen = true;
|
_allowOnlyOnePanelOpen = true;
|
||||||
@ -249,6 +251,9 @@ class ExpansionPanelList extends StatefulWidget {
|
|||||||
/// By default, the value of elevation is 2.
|
/// By default, the value of elevation is 2.
|
||||||
final double elevation;
|
final double elevation;
|
||||||
|
|
||||||
|
/// {@macro flutter.material.ExpandIcon.color}
|
||||||
|
final Color? expandIconColor;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _ExpansionPanelListState();
|
State<StatefulWidget> createState() => _ExpansionPanelListState();
|
||||||
}
|
}
|
||||||
@ -356,6 +361,7 @@ class _ExpansionPanelListState extends State<ExpansionPanelList> {
|
|||||||
Widget expandIconContainer = Container(
|
Widget expandIconContainer = Container(
|
||||||
margin: const EdgeInsetsDirectional.only(end: 8.0),
|
margin: const EdgeInsetsDirectional.only(end: 8.0),
|
||||||
child: ExpandIcon(
|
child: ExpandIcon(
|
||||||
|
color: widget.expandIconColor,
|
||||||
isExpanded: _isChildExpanded(index),
|
isExpanded: _isChildExpanded(index),
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
onPressed: !child.canTapOnHeader
|
onPressed: !child.canTapOnHeader
|
||||||
|
@ -1390,6 +1390,55 @@ void main() {
|
|||||||
expect(boxDecoration.border!.top.color, dividerColor);
|
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 {
|
testWidgets('elevation is propagated properly to MergeableMaterial', (WidgetTester tester) async {
|
||||||
const double elevation = 8;
|
const double elevation = 8;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user