Skip to content

Commit e57b7f4

Browse files
authored
Add Material 3 support for ListTile - Part 1 (#116194)
* Add Material 3 support for `ListTile` - Part 1 * minor refactor * Add `useMaterial3: false` to M2 tests
1 parent 55e7501 commit e57b7f4

File tree

6 files changed

+747
-230
lines changed

6 files changed

+747
-230
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';
@@ -154,6 +155,7 @@ Future<void> main(List<String> args) async {
154155
FilterChipTemplate('FilterChip', '$materialLib/filter_chip.dart', tokens).updateFile();
155156
IconButtonTemplate('IconButton', '$materialLib/icon_button.dart', tokens).updateFile();
156157
InputChipTemplate('InputChip', '$materialLib/input_chip.dart', tokens).updateFile();
158+
ListTileTemplate('LisTile', '$materialLib/list_tile.dart', tokens).updateFile();
157159
InputDecoratorTemplate('InputDecorator', '$materialLib/input_decorator.dart', tokens).updateFile();
158160
MenuTemplate('Menu', '$materialLib/menu_anchor.dart', tokens).updateFile();
159161
NavigationBarTemplate('NavigationBar', '$materialLib/navigation_bar.dart', tokens).updateFile();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
10+
@override
11+
String generate() => '''
12+
class _${blockName}DefaultsM3 extends ListTileThemeData {
13+
const _${blockName}DefaultsM3(this.context)
14+
: super(shape: ${shape("md.comp.list.list-item.container")});
15+
16+
final BuildContext context;
17+
18+
@override
19+
Color? get tileColor => ${componentColor("md.comp.list.list-item.container")};
20+
21+
@override
22+
TextStyle? get titleTextStyle => ${textStyle("md.comp.list.list-item.label-text")};
23+
24+
@override
25+
TextStyle? get subtitleTextStyle => ${textStyle("md.comp.list.list-item.supporting-text")};
26+
27+
@override
28+
TextStyle? get leadingAndTrailingTextStyle => ${textStyle("md.comp.list.list-item.trailing-supporting-text")};
29+
30+
@override
31+
Color? get selectedColor => ${componentColor('md.comp.list.list-item.selected.trailing-icon')};
32+
33+
@override
34+
Color? get iconColor => ${componentColor('md.comp.list.list-item.unselected.trailing-icon')};
35+
}
36+
''';
37+
}

0 commit comments

Comments
 (0)