Skip to content

Commit fa1a4ee

Browse files
authored
Update ListTile to support Material 3 (#117965)
* Update `ListTile` to support Material 3 * Update `Default ListTile debugFillProperties` * Add #99933 HTML workaround.
1 parent 31da712 commit fa1a4ee

File tree

6 files changed

+2081
-730
lines changed

6 files changed

+2081
-730
lines changed

dev/tools/gen_defaults/bin/gen_defaults.dart

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import 'package:gen_defaults/filter_chip_template.dart';
3535
import 'package:gen_defaults/icon_button_template.dart';
3636
import 'package:gen_defaults/input_chip_template.dart';
3737
import 'package:gen_defaults/input_decorator_template.dart';
38+
import 'package:gen_defaults/list_tile_template.dart';
3839
import 'package:gen_defaults/menu_template.dart';
3940
import 'package:gen_defaults/navigation_bar_template.dart';
4041
import 'package:gen_defaults/navigation_drawer_template.dart';
@@ -155,6 +156,7 @@ Future<void> main(List<String> args) async {
155156
FilterChipTemplate('FilterChip', '$materialLib/filter_chip.dart', tokens).updateFile();
156157
IconButtonTemplate('IconButton', '$materialLib/icon_button.dart', tokens).updateFile();
157158
InputChipTemplate('InputChip', '$materialLib/input_chip.dart', tokens).updateFile();
159+
ListTileTemplate('LisTile', '$materialLib/list_tile.dart', tokens).updateFile();
158160
InputDecoratorTemplate('InputDecorator', '$materialLib/input_decorator.dart', tokens).updateFile();
159161
MenuTemplate('Menu', '$materialLib/menu_anchor.dart', tokens).updateFile();
160162
NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2014 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'template.dart';
6+
7+
class ListTileTemplate extends TokenTemplate {
8+
const ListTileTemplate(super.blockName, super.fileName, super.tokens, {
9+
super.colorSchemePrefix = '_colors.',
10+
super.textThemePrefix = '_textTheme.',
11+
});
12+
13+
@override
14+
String generate() => '''
15+
class _${blockName}DefaultsM3 extends ListTileThemeData {
16+
_${blockName}DefaultsM3(this.context)
17+
: super(
18+
contentPadding: const EdgeInsetsDirectional.only(start: 16.0, end: 24.0),
19+
minLeadingWidth: 24,
20+
minVerticalPadding: 8,
21+
shape: ${shape("md.comp.list.list-item.container")},
22+
);
23+
24+
final BuildContext context;
25+
late final ThemeData _theme = Theme.of(context);
26+
late final ColorScheme _colors = _theme.colorScheme;
27+
late final TextTheme _textTheme = _theme.textTheme;
28+
29+
@override
30+
Color? get tileColor => Colors.transparent;
31+
32+
@override
33+
TextStyle? get titleTextStyle => ${textStyle("md.comp.list.list-item.label-text")};
34+
35+
@override
36+
TextStyle? get subtitleTextStyle => ${textStyle("md.comp.list.list-item.supporting-text")};
37+
38+
@override
39+
TextStyle? get leadingAndTrailingTextStyle => ${textStyle("md.comp.list.list-item.trailing-supporting-text")};
40+
41+
@override
42+
Color? get selectedColor => ${componentColor('md.comp.list.list-item.selected.trailing-icon')};
43+
44+
@override
45+
Color? get iconColor => ${componentColor('md.comp.list.list-item.unselected.trailing-icon')};
46+
}
47+
''';
48+
}

0 commit comments

Comments
 (0)