Commit 016f9390 authored by Kyle Bradshaw's avatar Kyle Bradshaw Committed by Ian Hickson

Trailing widget override for ExpansionTile (#11904)

* Trailing widget override for ExpansionTile

Fixes #11890

* Add a test

* Replaced missing comma
parent 33daa2f9
......@@ -38,6 +38,7 @@ class ExpansionTile extends StatefulWidget {
this.backgroundColor,
this.onExpansionChanged,
this.children: const <Widget>[],
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<ExpansionTile> 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),
),
......
......@@ -103,4 +103,33 @@ void main() {
await tester.tap(find.text('Sublist'));
expect(didChangeOpen, isFalse);
});
testWidgets('trailing override', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (_) {
return new Material(
child: new SingleChildScrollView(
child: new Column(
children: <Widget>[
const ListTile(title: const Text('Top')),
new ExpansionTile(
title: const Text('Sublist'),
children: <Widget>[
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);
});
}
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