Add dense property to AboutListTile (#37882)

This commit is contained in:
Shi-Hao Hong 2019-08-09 20:03:09 -04:00 committed by GitHub
parent 821602aef3
commit c7814d698d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 2 deletions

View File

@ -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,

View File

@ -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 {