Commit d961ae85 authored by Luiz França's avatar Luiz França Committed by Shi-Hao Hong

Adding subtitle to ExpansionTile (#43946)

* Adding subtitle to expansion_tile
parent dd597395
...@@ -35,6 +35,7 @@ class ExpansionTile extends StatefulWidget { ...@@ -35,6 +35,7 @@ class ExpansionTile extends StatefulWidget {
Key key, Key key,
this.leading, this.leading,
@required this.title, @required this.title,
this.subtitle,
this.backgroundColor, this.backgroundColor,
this.onExpansionChanged, this.onExpansionChanged,
this.children = const <Widget>[], this.children = const <Widget>[],
...@@ -53,6 +54,11 @@ class ExpansionTile extends StatefulWidget { ...@@ -53,6 +54,11 @@ class ExpansionTile extends StatefulWidget {
/// Typically a [Text] widget. /// Typically a [Text] widget.
final Widget title; final Widget title;
/// Additional content displayed below the title.
///
/// Typically a [Text] widget.
final Widget subtitle;
/// Called when the tile expands or collapses. /// Called when the tile expands or collapses.
/// ///
/// When the tile starts expanding, this function is called with the value /// When the tile starts expanding, this function is called with the value
...@@ -161,6 +167,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider ...@@ -161,6 +167,7 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
onTap: _handleTap, onTap: _handleTap,
leading: widget.leading, leading: widget.leading,
title: widget.title, title: widget.title,
subtitle: widget.subtitle,
trailing: widget.trailing ?? RotationTransition( trailing: widget.trailing ?? RotationTransition(
turns: _iconTurns, turns: _iconTurns,
child: const Icon(Icons.expand_more), child: const Icon(Icons.expand_more),
......
...@@ -215,4 +215,20 @@ void main() { ...@@ -215,4 +215,20 @@ void main() {
expect(iconColor(expandedIconKey), _unselectedWidgetColor); expect(iconColor(expandedIconKey), _unselectedWidgetColor);
expect(iconColor(collapsedIconKey), _accentColor); 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);
});
} }
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