Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
Update ListTile font (#101900)
Browse files Browse the repository at this point in the history
  • Loading branch information
TahaTesser authored Apr 18, 2022
1 parent d0d816c commit 9f0bcfb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 9 additions & 9 deletions packages/flutter/lib/src/material/list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import 'theme_data.dart';

/// Defines the title font used for [ListTile] descendants of a [ListTileTheme].
///
/// List tiles that appear in a [Drawer] use the theme's [TextTheme.bodyText1]
/// text style, which is a little smaller than the theme's [TextTheme.subtitle1]
/// List tiles that appear in a [Drawer] use the theme's [TextTheme.bodyMedium]
/// text style, which is a little smaller than the theme's [TextTheme.titleMedium]
/// text style, which is used by default.
enum ListTileStyle {
/// Use a title font that's appropriate for a [ListTile] in a list.
Expand Down Expand Up @@ -356,14 +356,14 @@ class ListTile extends StatelessWidget {
/// two lines. For example, you can use [Text.maxLines] to enforce the number
/// of lines.
///
/// The subtitle's default [TextStyle] depends on [TextTheme.bodyText2] except
/// The subtitle's default [TextStyle] depends on [TextTheme.bodyMedium] except
/// [TextStyle.color]. The [TextStyle.color] depends on the value of [enabled]
/// and [selected].
///
/// When [enabled] is false, the text color is set to [ThemeData.disabledColor].
///
/// When [selected] is false, the text color is set to [ListTileTheme.textColor]
/// if it's not null and to [TextTheme.caption]'s color if [ListTileTheme.textColor]
/// if it's not null and to [TextTheme.bodySmall]'s color if [ListTileTheme.textColor]
/// is null.
final Widget? subtitle;

Expand Down Expand Up @@ -654,10 +654,10 @@ class ListTile extends StatelessWidget {
final TextStyle textStyle;
switch(style ?? tileTheme.style ?? theme.listTileTheme.style ?? ListTileStyle.list) {
case ListTileStyle.drawer:
textStyle = theme.textTheme.bodyText1!;
textStyle = theme.textTheme.bodyMedium!;
break;
case ListTileStyle.list:
textStyle = theme.textTheme.subtitle1!;
textStyle = theme.textTheme.titleMedium!;
break;
}
final Color? color = _textColor(theme, tileTheme, textStyle.color);
Expand All @@ -667,15 +667,15 @@ class ListTile extends StatelessWidget {
}

TextStyle _subtitleTextStyle(ThemeData theme, ListTileThemeData tileTheme) {
final TextStyle textStyle = theme.textTheme.bodyText2!;
final Color? color = _textColor(theme, tileTheme, theme.textTheme.caption!.color);
final TextStyle textStyle = theme.textTheme.bodyMedium!;
final Color? color = _textColor(theme, tileTheme, theme.textTheme.bodySmall!.color);
return _isDenseLayout(theme, tileTheme)
? textStyle.copyWith(color: color, fontSize: 12.0)
: textStyle.copyWith(color: color);
}

TextStyle _trailingAndLeadingTextStyle(ThemeData theme, ListTileThemeData tileTheme) {
final TextStyle textStyle = theme.textTheme.bodyText2!;
final TextStyle textStyle = theme.textTheme.bodyMedium!;
final Color? color = _textColor(theme, tileTheme, textStyle.color);
return textStyle.copyWith(color: color);
}
Expand Down
16 changes: 8 additions & 8 deletions packages/flutter/test/material/list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2208,25 +2208,25 @@ void main() {
// ListTile - ListTileStyle.list (default).
await tester.pumpWidget(buildFrame());
RenderParagraph leading = _getTextRenderObject(tester, 'leading');
expect(leading.text.style!.color, theme.textTheme.bodyText2!.color);
expect(leading.text.style!.color, theme.textTheme.bodyMedium!.color);
RenderParagraph title = _getTextRenderObject(tester, 'title');
expect(title.text.style!.color, theme.textTheme.subtitle1!.color);
expect(title.text.style!.color, theme.textTheme.titleMedium!.color);
RenderParagraph subtitle = _getTextRenderObject(tester, 'subtitle');
expect(subtitle.text.style!.color, theme.textTheme.caption!.color);
expect(subtitle.text.style!.color, theme.textTheme.bodySmall!.color);
RenderParagraph trailing = _getTextRenderObject(tester, 'trailing');
expect(trailing.text.style!.color, theme.textTheme.bodyText2!.color);
expect(trailing.text.style!.color, theme.textTheme.bodyMedium!.color);

// ListTile - ListTileStyle.drawer.
await tester.pumpWidget(buildFrame(style: ListTileStyle.drawer));
await tester.pumpAndSettle();
leading = _getTextRenderObject(tester, 'leading');
expect(leading.text.style!.color, theme.textTheme.bodyText2!.color);
expect(leading.text.style!.color, theme.textTheme.bodyMedium!.color);
title = _getTextRenderObject(tester, 'title');
expect(title.text.style!.color, theme.textTheme.bodyText1!.color);
expect(title.text.style!.color, theme.textTheme.bodyLarge!.color);
subtitle = _getTextRenderObject(tester, 'subtitle');
expect(subtitle.text.style!.color, theme.textTheme.caption!.color);
expect(subtitle.text.style!.color, theme.textTheme.bodySmall!.color);
trailing = _getTextRenderObject(tester, 'trailing');
expect(trailing.text.style!.color, theme.textTheme.bodyText2!.color);
expect(trailing.text.style!.color, theme.textTheme.bodyMedium!.color);
});

testWidgets('Default ListTile debugFillProperties', (WidgetTester tester) async {
Expand Down

0 comments on commit 9f0bcfb

Please sign in to comment.