@@ -2104,6 +2104,7 @@ void main() {
2104
2104
ListTileStyle ? style,
2105
2105
}) {
2106
2106
return MaterialApp (
2107
+ theme: ThemeData (useMaterial3: true ),
2107
2108
home: Material (
2108
2109
child: Center (
2109
2110
child: Builder (
@@ -2181,6 +2182,7 @@ void main() {
2181
2182
ListTileStyle ? style,
2182
2183
}) {
2183
2184
return MaterialApp (
2185
+ theme: ThemeData (useMaterial3: true ),
2184
2186
home: Material (
2185
2187
child: Center (
2186
2188
child: Builder (
@@ -2207,25 +2209,25 @@ void main() {
2207
2209
// ListTile - ListTileStyle.list (default).
2208
2210
await tester.pumpWidget (buildFrame ());
2209
2211
RenderParagraph leading = _getTextRenderObject (tester, 'leading' );
2210
- expect (leading.text.style! .color, theme.textTheme.bodyText2 ! .color);
2212
+ expect (leading.text.style! .color, theme.textTheme.bodyMedium ! .color);
2211
2213
RenderParagraph title = _getTextRenderObject (tester, 'title' );
2212
- expect (title.text.style! .color, theme.textTheme.subtitle1 ! .color);
2214
+ expect (title.text.style! .color, theme.textTheme.titleMedium ! .color);
2213
2215
RenderParagraph subtitle = _getTextRenderObject (tester, 'subtitle' );
2214
- expect (subtitle.text.style! .color, theme.textTheme.caption ! .color);
2216
+ expect (subtitle.text.style! .color, theme.textTheme.bodySmall ! .color);
2215
2217
RenderParagraph trailing = _getTextRenderObject (tester, 'trailing' );
2216
- expect (trailing.text.style! .color, theme.textTheme.bodyText2 ! .color);
2218
+ expect (trailing.text.style! .color, theme.textTheme.bodyMedium ! .color);
2217
2219
2218
2220
// ListTile - ListTileStyle.drawer.
2219
2221
await tester.pumpWidget (buildFrame (style: ListTileStyle .drawer));
2220
2222
await tester.pumpAndSettle ();
2221
2223
leading = _getTextRenderObject (tester, 'leading' );
2222
- expect (leading.text.style! .color, theme.textTheme.bodyText2 ! .color);
2224
+ expect (leading.text.style! .color, theme.textTheme.bodyMedium ! .color);
2223
2225
title = _getTextRenderObject (tester, 'title' );
2224
- expect (title.text.style! .color, theme.textTheme.bodyText1 ! .color);
2226
+ expect (title.text.style! .color, theme.textTheme.bodyLarge ! .color);
2225
2227
subtitle = _getTextRenderObject (tester, 'subtitle' );
2226
- expect (subtitle.text.style! .color, theme.textTheme.caption ! .color);
2228
+ expect (subtitle.text.style! .color, theme.textTheme.bodySmall ! .color);
2227
2229
trailing = _getTextRenderObject (tester, 'trailing' );
2228
- expect (trailing.text.style! .color, theme.textTheme.bodyText2 ! .color);
2230
+ expect (trailing.text.style! .color, theme.textTheme.bodyMedium ! .color);
2229
2231
});
2230
2232
2231
2233
testWidgets ('Default ListTile debugFillProperties' , (WidgetTester tester) async {
@@ -2299,6 +2301,143 @@ void main() {
2299
2301
expect (description[22 ], 'minVerticalPadding: 2.0' );
2300
2302
expect (description[23 ], 'minLeadingWidth: 6.0' );
2301
2303
});
2304
+
2305
+ group ('Material 2' , () {
2306
+ // Tests that are only relevant for Material 2. Once ThemeData.useMaterial3
2307
+ // is turned on by default, these tests can be removed.
2308
+
2309
+ testWidgets ('ListTile font size' , (WidgetTester tester) async {
2310
+ Widget buildFrame ({
2311
+ bool dense = false ,
2312
+ bool enabled = true ,
2313
+ bool selected = false ,
2314
+ ListTileStyle ? style,
2315
+ }) {
2316
+ return MaterialApp (
2317
+ home: Material (
2318
+ child: Center (
2319
+ child: Builder (
2320
+ builder: (BuildContext context) {
2321
+ return ListTile (
2322
+ dense: dense,
2323
+ enabled: enabled,
2324
+ selected: selected,
2325
+ style: style,
2326
+ leading: const TestText ('leading' ),
2327
+ title: const TestText ('title' ),
2328
+ subtitle: const TestText ('subtitle' ) ,
2329
+ trailing: const TestText ('trailing' ),
2330
+ );
2331
+ },
2332
+ ),
2333
+ ),
2334
+ ),
2335
+ );
2336
+ }
2337
+
2338
+ // ListTile - ListTileStyle.list (default).
2339
+ await tester.pumpWidget (buildFrame ());
2340
+ RenderParagraph leading = _getTextRenderObject (tester, 'leading' );
2341
+ expect (leading.text.style! .fontSize, 14.0 );
2342
+ RenderParagraph title = _getTextRenderObject (tester, 'title' );
2343
+ expect (title.text.style! .fontSize, 16.0 );
2344
+ RenderParagraph subtitle = _getTextRenderObject (tester, 'subtitle' );
2345
+ expect (subtitle.text.style! .fontSize, 14.0 );
2346
+ RenderParagraph trailing = _getTextRenderObject (tester, 'trailing' );
2347
+ expect (trailing.text.style! .fontSize, 14.0 );
2348
+
2349
+ // ListTile - Densed - ListTileStyle.list (default).
2350
+ await tester.pumpWidget (buildFrame (dense: true ));
2351
+ await tester.pumpAndSettle ();
2352
+ leading = _getTextRenderObject (tester, 'leading' );
2353
+ expect (leading.text.style! .fontSize, 14.0 );
2354
+ title = _getTextRenderObject (tester, 'title' );
2355
+ expect (title.text.style! .fontSize, 13.0 );
2356
+ subtitle = _getTextRenderObject (tester, 'subtitle' );
2357
+ expect (subtitle.text.style! .fontSize, 12.0 );
2358
+ trailing = _getTextRenderObject (tester, 'trailing' );
2359
+ expect (trailing.text.style! .fontSize, 14.0 );
2360
+
2361
+ // ListTile - ListTileStyle.drawer.
2362
+ await tester.pumpWidget (buildFrame (style: ListTileStyle .drawer));
2363
+ await tester.pumpAndSettle ();
2364
+ leading = _getTextRenderObject (tester, 'leading' );
2365
+ expect (leading.text.style! .fontSize, 14.0 );
2366
+ title = _getTextRenderObject (tester, 'title' );
2367
+ expect (title.text.style! .fontSize, 14.0 );
2368
+ subtitle = _getTextRenderObject (tester, 'subtitle' );
2369
+ expect (subtitle.text.style! .fontSize, 14.0 );
2370
+ trailing = _getTextRenderObject (tester, 'trailing' );
2371
+ expect (trailing.text.style! .fontSize, 14.0 );
2372
+
2373
+ // ListTile - Densed - ListTileStyle.drawer.
2374
+ await tester.pumpWidget (buildFrame (dense: true , style: ListTileStyle .drawer));
2375
+ await tester.pumpAndSettle ();
2376
+ leading = _getTextRenderObject (tester, 'leading' );
2377
+ expect (leading.text.style! .fontSize, 14.0 );
2378
+ title = _getTextRenderObject (tester, 'title' );
2379
+ expect (title.text.style! .fontSize, 13.0 );
2380
+ subtitle = _getTextRenderObject (tester, 'subtitle' );
2381
+ expect (subtitle.text.style! .fontSize, 12.0 );
2382
+ trailing = _getTextRenderObject (tester, 'trailing' );
2383
+ expect (trailing.text.style! .fontSize, 14.0 );
2384
+ });
2385
+
2386
+ testWidgets ('ListTile text color' , (WidgetTester tester) async {
2387
+ Widget buildFrame ({
2388
+ bool dense = false ,
2389
+ bool enabled = true ,
2390
+ bool selected = false ,
2391
+ ListTileStyle ? style,
2392
+ }) {
2393
+ return MaterialApp (
2394
+ home: Material (
2395
+ child: Center (
2396
+ child: Builder (
2397
+ builder: (BuildContext context) {
2398
+ return ListTile (
2399
+ dense: dense,
2400
+ enabled: enabled,
2401
+ selected: selected,
2402
+ style: style,
2403
+ leading: const TestText ('leading' ),
2404
+ title: const TestText ('title' ),
2405
+ subtitle: const TestText ('subtitle' ) ,
2406
+ trailing: const TestText ('trailing' ),
2407
+ );
2408
+ },
2409
+ ),
2410
+ ),
2411
+ ),
2412
+ );
2413
+ }
2414
+
2415
+ final ThemeData theme = ThemeData ();
2416
+
2417
+ // ListTile - ListTileStyle.list (default).
2418
+ await tester.pumpWidget (buildFrame ());
2419
+ RenderParagraph leading = _getTextRenderObject (tester, 'leading' );
2420
+ expect (leading.text.style! .color, theme.textTheme.bodyText2! .color);
2421
+ RenderParagraph title = _getTextRenderObject (tester, 'title' );
2422
+ expect (title.text.style! .color, theme.textTheme.subtitle1! .color);
2423
+ RenderParagraph subtitle = _getTextRenderObject (tester, 'subtitle' );
2424
+ expect (subtitle.text.style! .color, theme.textTheme.caption! .color);
2425
+ RenderParagraph trailing = _getTextRenderObject (tester, 'trailing' );
2426
+ expect (trailing.text.style! .color, theme.textTheme.bodyText2! .color);
2427
+
2428
+ // ListTile - ListTileStyle.drawer.
2429
+ await tester.pumpWidget (buildFrame (style: ListTileStyle .drawer));
2430
+ await tester.pumpAndSettle ();
2431
+ leading = _getTextRenderObject (tester, 'leading' );
2432
+ expect (leading.text.style! .color, theme.textTheme.bodyText2! .color);
2433
+ title = _getTextRenderObject (tester, 'title' );
2434
+ expect (title.text.style! .color, theme.textTheme.subtitle1! .color);
2435
+ subtitle = _getTextRenderObject (tester, 'subtitle' );
2436
+ expect (subtitle.text.style! .color, theme.textTheme.caption! .color);
2437
+ trailing = _getTextRenderObject (tester, 'trailing' );
2438
+ expect (trailing.text.style! .color, theme.textTheme.bodyText2! .color);
2439
+ });
2440
+ });
2302
2441
}
2303
2442
2304
2443
RenderParagraph _getTextRenderObject (WidgetTester tester, String text) {
0 commit comments