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.applicationIcon,
|
||||||
this.applicationLegalese,
|
this.applicationLegalese,
|
||||||
this.aboutBoxChildren,
|
this.aboutBoxChildren,
|
||||||
|
this.dense,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// The icon to show for this drawer item.
|
/// The icon to show for this drawer item.
|
||||||
@ -106,14 +107,23 @@ class AboutListTile extends StatelessWidget {
|
|||||||
/// Defaults to nothing.
|
/// Defaults to nothing.
|
||||||
final List<Widget> aboutBoxChildren;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
assert(debugCheckHasMaterial(context));
|
assert(debugCheckHasMaterial(context));
|
||||||
assert(debugCheckHasMaterialLocalizations(context));
|
assert(debugCheckHasMaterialLocalizations(context));
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: icon,
|
leading: icon,
|
||||||
title: child ??
|
title: child ?? Text(MaterialLocalizations.of(context).aboutListTileTitle(
|
||||||
Text(MaterialLocalizations.of(context).aboutListTileTitle(applicationName ?? _defaultApplicationName(context))),
|
applicationName ?? _defaultApplicationName(context),
|
||||||
|
)),
|
||||||
|
dense: dense,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
showAboutDialog(
|
showAboutDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -285,6 +285,26 @@ void main() {
|
|||||||
);
|
);
|
||||||
expect(find.text('flutter_tester'), findsOneWidget);
|
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 {
|
class FakeLicenseEntry extends LicenseEntry {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user