Unverified Commit c7814d69 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

Add dense property to AboutListTile (#37882)

parent 821602ae
......@@ -48,6 +48,7 @@ class AboutListTile extends StatelessWidget {
this.applicationIcon,
this.applicationLegalese,
this.aboutBoxChildren,
this.dense,
}) : super(key: key);
/// The icon to show for this drawer item.
......@@ -106,14 +107,23 @@ class AboutListTile extends StatelessWidget {
/// Defaults to nothing.
final List<Widget> aboutBoxChildren;
/// Whether this list tile is part of a vertically dense list.
///
/// If this property is null, then its value is based on [ListTileTheme.dense].
///
/// Dense list tiles default to a smaller height.
final bool dense;
@override
Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context));
assert(debugCheckHasMaterialLocalizations(context));
return ListTile(
leading: icon,
title: child ??
Text(MaterialLocalizations.of(context).aboutListTileTitle(applicationName ?? _defaultApplicationName(context))),
title: child ?? Text(MaterialLocalizations.of(context).aboutListTileTitle(
applicationName ?? _defaultApplicationName(context),
)),
dense: dense,
onTap: () {
showAboutDialog(
context: context,
......
......@@ -285,6 +285,26 @@ void main() {
);
expect(find.text('flutter_tester'), findsOneWidget);
});
testWidgets('AboutListTile dense property is applied', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Material(child: Center(child: AboutListTile())),
));
Rect tileRect = tester.getRect(find.byType(AboutListTile));
expect(tileRect.height, 56.0);
await tester.pumpWidget(const MaterialApp(
home: Material(child: Center(child: AboutListTile(dense: false))),
));
tileRect = tester.getRect(find.byType(AboutListTile));
expect(tileRect.height, 56.0);
await tester.pumpWidget(const MaterialApp(
home: Material(child: Center(child: AboutListTile(dense: true))),
));
tileRect = tester.getRect(find.byType(AboutListTile));
expect(tileRect.height, 48.0);
});
}
class FakeLicenseEntry extends LicenseEntry {
......
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