diff --git a/packages/flutter/lib/src/material/expansion_tile.dart b/packages/flutter/lib/src/material/expansion_tile.dart index e00405e8da..a32656914d 100644 --- a/packages/flutter/lib/src/material/expansion_tile.dart +++ b/packages/flutter/lib/src/material/expansion_tile.dart @@ -38,6 +38,7 @@ class ExpansionTile extends StatefulWidget { this.backgroundColor, this.onExpansionChanged, this.children: const [], + this.trailing, }) : super(key: key); /// A widget to display before the title. @@ -64,6 +65,9 @@ class ExpansionTile extends StatefulWidget { /// The color to display behind the sublist when expanded. final Color backgroundColor; + + /// A widget to display instead of a rotating arrow icon. + final Widget trailing; @override _ExpansionTileState createState() => new _ExpansionTileState(); @@ -145,7 +149,7 @@ class _ExpansionTileState extends State with SingleTickerProvider style: Theme.of(context).textTheme.subhead.copyWith(color: titleColor), child: widget.title, ), - trailing: new RotationTransition( + trailing: widget.trailing ?? new RotationTransition( turns: _iconTurns, child: const Icon(Icons.expand_more), ), diff --git a/packages/flutter/test/material/two_level_list_test.dart b/packages/flutter/test/material/two_level_list_test.dart index 3670d54caa..1e1bada25d 100644 --- a/packages/flutter/test/material/two_level_list_test.dart +++ b/packages/flutter/test/material/two_level_list_test.dart @@ -103,4 +103,33 @@ void main() { await tester.tap(find.text('Sublist')); expect(didChangeOpen, isFalse); }); + + testWidgets('trailing override', (WidgetTester tester) async { + final Map routes = { + '/': (_) { + return new Material( + child: new SingleChildScrollView( + child: new Column( + children: [ + const ListTile(title: const Text('Top')), + new ExpansionTile( + title: const Text('Sublist'), + children: [ + const ListTile(title: const Text('0')), + const ListTile(title: const Text('1')) + ], + trailing: const Icon(Icons.inbox), + ), + const ListTile(title: const Text('Bottom')) + ] + ) + ) + ); + } + }; + + await tester.pumpWidget(new MaterialApp(routes: routes)); + expect(find.byIcon(Icons.inbox), findsOneWidget); + expect(find.byIcon(Icons.expand_more), findsNothing); + }); }