From 9f0bcfb82499e22a29b786753c469e4d42ae1342 Mon Sep 17 00:00:00 2001 From: Taha Tesser Date: Mon, 18 Apr 2022 19:42:00 +0300 Subject: [PATCH] Update `ListTile` font (#101900) --- .../flutter/lib/src/material/list_tile.dart | 18 +++++++++--------- .../flutter/test/material/list_tile_test.dart | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 5dd7aec93cd9..21b9e9effcf9 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -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. @@ -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; @@ -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); @@ -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); } diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index 1a3adc76be36..e6ce045ab9d2 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -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 {