Skip to content

Commit

Permalink
Fix ListTile's default iconColor token used & update examples (#1…
Browse files Browse the repository at this point in the history
…20444)
  • Loading branch information
TahaTesser authored Feb 13, 2023
1 parent f4495f5 commit 402caec
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dev/tools/gen_defaults/lib/list_tile_template.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class _${blockName}DefaultsM3 extends ListTileThemeData {
Color? get selectedColor => ${componentColor('md.comp.list.list-item.selected.trailing-icon')};
@override
Color? get iconColor => ${componentColor('md.comp.list.list-item.unselected.trailing-icon')};
Color? get iconColor => ${componentColor('md.comp.list.list-item.trailing-icon')};
}
''';
}
3 changes: 2 additions & 1 deletion examples/api/lib/material/list_tile/list_tile.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ListTileApp extends StatelessWidget {
theme: ThemeData(
listTileTheme: const ListTileThemeData(
textColor: Colors.white,
)
),
useMaterial3: true,
),
home: const LisTileExample(),
);
Expand Down
5 changes: 3 additions & 2 deletions examples/api/lib/material/list_tile/list_tile.1.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ListTileApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: LisTileExample(),
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const LisTileExample(),
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/api/lib/material/list_tile/list_tile.2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ListTileApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
theme: ThemeData(useMaterial3: true),
home: const ListTileExample(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/api/lib/material/list_tile/list_tile.3.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ListTileApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(colorSchemeSeed: const Color(0xff6750a4), useMaterial3: true),
theme: ThemeData(useMaterial3: true),
home: const ListTileExample(),
);
}
Expand Down
5 changes: 3 additions & 2 deletions examples/api/lib/material/list_tile/list_tile.selected.0.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ class ListTileApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: LisTileExample(),
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const LisTileExample(),
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class ListTile extends StatelessWidget {
/// Defines the default color for [leading] and [trailing] icons.
///
/// If this property is null and [selected] is false then [ListTileThemeData.iconColor]
/// is used. If that is also null and [ThemeData.useMaterial3] is true, [ColorScheme.onSurface]
/// is used. If that is also null and [ThemeData.useMaterial3] is true, [ColorScheme.onSurfaceVariant]
/// is used, otherwise if [ThemeData.brightness] is [Brightness.light], [Colors.black54] is used,
/// and if [ThemeData.brightness] is [Brightness.dark], the value is null.
///
Expand Down Expand Up @@ -1593,7 +1593,7 @@ class _LisTileDefaultsM3 extends ListTileThemeData {
Color? get selectedColor => _colors.primary;

@override
Color? get iconColor => _colors.onSurface;
Color? get iconColor => _colors.onSurfaceVariant;
}

// END GENERATED TOKEN PROPERTIES - LisTile
8 changes: 4 additions & 4 deletions packages/flutter/test/material/list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1882,10 +1882,10 @@ void main() {
expect(iconColor(trailingKey), colorScheme.primary);

await tester.pumpWidget(buildFrame(selected: false));
expect(iconColor(leadingKey), colorScheme.onSurface);
expect(iconColor(titleKey), colorScheme.onSurface);
expect(iconColor(subtitleKey), colorScheme.onSurface);
expect(iconColor(trailingKey), colorScheme.onSurface);
expect(iconColor(leadingKey), colorScheme.onSurfaceVariant);
expect(iconColor(titleKey), colorScheme.onSurfaceVariant);
expect(iconColor(subtitleKey), colorScheme.onSurfaceVariant);
expect(iconColor(trailingKey), colorScheme.onSurfaceVariant);
});

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

0 comments on commit 402caec

Please sign in to comment.