From d961ae85b5b8e7c073ce09498291055ced9619e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Fran=C3=A7a?= Date: Fri, 8 Nov 2019 15:04:49 -0300 Subject: [PATCH] Adding subtitle to ExpansionTile (#43946) * Adding subtitle to expansion_tile --- .../flutter/lib/src/material/expansion_tile.dart | 7 +++++++ .../test/material/expansion_tile_test.dart | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/packages/flutter/lib/src/material/expansion_tile.dart b/packages/flutter/lib/src/material/expansion_tile.dart index 4eaed6ae43..bc96bd5c65 100644 --- a/packages/flutter/lib/src/material/expansion_tile.dart +++ b/packages/flutter/lib/src/material/expansion_tile.dart @@ -35,6 +35,7 @@ class ExpansionTile extends StatefulWidget { Key key, this.leading, @required this.title, + this.subtitle, this.backgroundColor, this.onExpansionChanged, this.children = const [], @@ -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 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), diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index 96db2dc85b..8904112c7d 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -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: [ListTile(title: Text('0'))], + ), + ), + ), + ); + + expect(find.text('Subtitle'), findsOneWidget); + }); }