Adding subtitle to ExpansionTile (#43946)
* Adding subtitle to expansion_tile
This commit is contained in:
committed by
Shi-Hao Hong
parent
dd59739513
commit
d961ae85b5
@@ -35,6 +35,7 @@ class ExpansionTile extends StatefulWidget {
|
||||
Key key,
|
||||
this.leading,
|
||||
@required this.title,
|
||||
this.subtitle,
|
||||
this.backgroundColor,
|
||||
this.onExpansionChanged,
|
||||
this.children = const <Widget>[],
|
||||
@@ -53,6 +54,11 @@ class ExpansionTile extends StatefulWidget {
|
||||
/// Typically a [Text] widget.
|
||||
final Widget title;
|
||||
|
||||
/// Additional content displayed below the title.
|
||||
///
|
||||
/// Typically a [Text] widget.
|
||||
final Widget subtitle;
|
||||
|
||||
/// Called when the tile expands or collapses.
|
||||
///
|
||||
/// When the tile starts expanding, this function is called with the value
|
||||
@@ -161,6 +167,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
|
||||
onTap: _handleTap,
|
||||
leading: widget.leading,
|
||||
title: widget.title,
|
||||
subtitle: widget.subtitle,
|
||||
trailing: widget.trailing ?? RotationTransition(
|
||||
turns: _iconTurns,
|
||||
child: const Icon(Icons.expand_more),
|
||||
|
||||
@@ -215,4 +215,20 @@ void main() {
|
||||
expect(iconColor(expandedIconKey), _unselectedWidgetColor);
|
||||
expect(iconColor(collapsedIconKey), _accentColor);
|
||||
});
|
||||
|
||||
testWidgets('ExpansionTile subtitle', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ExpansionTile(
|
||||
title: Text('Title'),
|
||||
subtitle: Text('Subtitle'),
|
||||
children: <Widget>[ListTile(title: Text('0'))],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Subtitle'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user