Skip to content

Commit 402caec

Browse files
authored
Fix ListTile's default iconColor token used & update examples (#120444)
1 parent f4495f5 commit 402caec

File tree

8 files changed

+17
-14
lines changed

8 files changed

+17
-14
lines changed

dev/tools/gen_defaults/lib/list_tile_template.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class _${blockName}DefaultsM3 extends ListTileThemeData {
4242
Color? get selectedColor => ${componentColor('md.comp.list.list-item.selected.trailing-icon')};
4343
4444
@override
45-
Color? get iconColor => ${componentColor('md.comp.list.list-item.unselected.trailing-icon')};
45+
Color? get iconColor => ${componentColor('md.comp.list.list-item.trailing-icon')};
4646
}
4747
''';
4848
}

examples/api/lib/material/list_tile/list_tile.0.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class ListTileApp extends StatelessWidget {
1717
theme: ThemeData(
1818
listTileTheme: const ListTileThemeData(
1919
textColor: Colors.white,
20-
)
20+
),
21+
useMaterial3: true,
2122
),
2223
home: const LisTileExample(),
2324
);

examples/api/lib/material/list_tile/list_tile.1.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ class ListTileApp extends StatelessWidget {
1313

1414
@override
1515
Widget build(BuildContext context) {
16-
return const MaterialApp(
17-
home: LisTileExample(),
16+
return MaterialApp(
17+
theme: ThemeData(useMaterial3: true),
18+
home: const LisTileExample(),
1819
);
1920
}
2021
}

examples/api/lib/material/list_tile/list_tile.2.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ListTileApp extends StatelessWidget {
1414
@override
1515
Widget build(BuildContext context) {
1616
return MaterialApp(
17-
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
17+
theme: ThemeData(useMaterial3: true),
1818
home: const ListTileExample(),
1919
);
2020
}

examples/api/lib/material/list_tile/list_tile.3.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ListTileApp extends StatelessWidget {
1414
@override
1515
Widget build(BuildContext context) {
1616
return MaterialApp(
17-
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
17+
theme: ThemeData(useMaterial3: true),
1818
home: const ListTileExample(),
1919
);
2020
}

examples/api/lib/material/list_tile/list_tile.selected.0.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ class ListTileApp extends StatelessWidget {
1313

1414
@override
1515
Widget build(BuildContext context) {
16-
return const MaterialApp(
17-
home: LisTileExample(),
16+
return MaterialApp(
17+
theme: ThemeData(useMaterial3: true),
18+
home: const LisTileExample(),
1819
);
1920
}
2021
}

packages/flutter/lib/src/material/list_tile.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ class ListTile extends StatelessWidget {
474474
/// Defines the default color for [leading] and [trailing] icons.
475475
///
476476
/// If this property is null and [selected] is false then [ListTileThemeData.iconColor]
477-
/// is used. If that is also null and [ThemeData.useMaterial3] is true, [ColorScheme.onSurface]
477+
/// is used. If that is also null and [ThemeData.useMaterial3] is true, [ColorScheme.onSurfaceVariant]
478478
/// is used, otherwise if [ThemeData.brightness] is [Brightness.light], [Colors.black54] is used,
479479
/// and if [ThemeData.brightness] is [Brightness.dark], the value is null.
480480
///
@@ -1593,7 +1593,7 @@ class _LisTileDefaultsM3 extends ListTileThemeData {
15931593
Color? get selectedColor => _colors.primary;
15941594

15951595
@override
1596-
Color? get iconColor => _colors.onSurface;
1596+
Color? get iconColor => _colors.onSurfaceVariant;
15971597
}
15981598

15991599
// END GENERATED TOKEN PROPERTIES - LisTile

packages/flutter/test/material/list_tile_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,10 +1882,10 @@ void main() {
18821882
expect(iconColor(trailingKey), colorScheme.primary);
18831883

18841884
await tester.pumpWidget(buildFrame(selected: false));
1885-
expect(iconColor(leadingKey), colorScheme.onSurface);
1886-
expect(iconColor(titleKey), colorScheme.onSurface);
1887-
expect(iconColor(subtitleKey), colorScheme.onSurface);
1888-
expect(iconColor(trailingKey), colorScheme.onSurface);
1885+
expect(iconColor(leadingKey), colorScheme.onSurfaceVariant);
1886+
expect(iconColor(titleKey), colorScheme.onSurfaceVariant);
1887+
expect(iconColor(subtitleKey), colorScheme.onSurfaceVariant);
1888+
expect(iconColor(trailingKey), colorScheme.onSurfaceVariant);
18891889
});
18901890

18911891
testWidgets('ListTile font size', (WidgetTester tester) async {

0 commit comments

Comments
 (0)