Add dense property to AboutListTile (#37882)
This commit is contained in:
parent
821602aef3
commit
c7814d698d
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user