@@ -4361,6 +4361,138 @@ void main() {
4361
4361
expect (trailingOffset.dy - tileOffset.dy, minVerticalPadding);
4362
4362
});
4363
4363
});
4364
+
4365
+ // Regression test for https://github.com/flutter/flutter/issues/165453
4366
+ testWidgets ('ListTile isThreeLine' , (WidgetTester tester) async {
4367
+ const double height = 300 ;
4368
+ const double avatarTop = 130.0 ;
4369
+ const double placeholderTop = 138.0 ;
4370
+
4371
+ Widget buildFrame ({bool ? themeDataIsThreeLine, bool ? themeIsThreeLine, bool ? isThreeLine}) {
4372
+ return MaterialApp (
4373
+ key: UniqueKey (),
4374
+ theme:
4375
+ themeDataIsThreeLine != null
4376
+ ? ThemeData (listTileTheme: ListTileThemeData (isThreeLine: themeDataIsThreeLine))
4377
+ : null ,
4378
+ home: Material (
4379
+ child: ListTileTheme (
4380
+ data:
4381
+ themeIsThreeLine != null ? ListTileThemeData (isThreeLine: themeIsThreeLine) : null ,
4382
+ child: ListView (
4383
+ children: < Widget > [
4384
+ ListTile (
4385
+ isThreeLine: isThreeLine,
4386
+ leading: const CircleAvatar (),
4387
+ trailing: const SizedBox (height: 24.0 , width: 24.0 , child: Placeholder ()),
4388
+ title: const Text ('A' ),
4389
+ subtitle: const Text ('A\n B\n C\n D\n E\n F\n G\n H\n I\n J\n K\n L\n M' ),
4390
+ ),
4391
+ ListTile (
4392
+ isThreeLine: isThreeLine,
4393
+ leading: const CircleAvatar (),
4394
+ trailing: const SizedBox (height: 24.0 , width: 24.0 , child: Placeholder ()),
4395
+ title: const Text ('A' ),
4396
+ subtitle: const Text ('A' ),
4397
+ ),
4398
+ ],
4399
+ ),
4400
+ ),
4401
+ ),
4402
+ );
4403
+ }
4404
+
4405
+ void expectTwoLine () {
4406
+ expect (
4407
+ tester.getRect (find.byType (ListTile ).at (0 )),
4408
+ const Rect .fromLTWH (0.0 , 0.0 , 800.0 , height),
4409
+ );
4410
+ expect (
4411
+ tester.getRect (find.byType (CircleAvatar ).at (0 )),
4412
+ const Rect .fromLTWH (16.0 , avatarTop, 40.0 , 40.0 ),
4413
+ );
4414
+ expect (
4415
+ tester.getRect (find.byType (Placeholder ).at (0 )),
4416
+ const Rect .fromLTWH (800.0 - 24.0 - 24.0 , placeholderTop, 24.0 , 24.0 ),
4417
+ );
4418
+ expect (
4419
+ tester.getRect (find.byType (ListTile ).at (1 )),
4420
+ const Rect .fromLTWH (0.0 , height, 800.0 , 72.0 ),
4421
+ );
4422
+ expect (
4423
+ tester.getRect (find.byType (CircleAvatar ).at (1 )),
4424
+ const Rect .fromLTWH (16.0 , height + 16.0 , 40.0 , 40.0 ),
4425
+ );
4426
+ expect (
4427
+ tester.getRect (find.byType (Placeholder ).at (1 )),
4428
+ const Rect .fromLTWH (800.0 - 24.0 - 24.0 , height + 24.0 , 24.0 , 24.0 ),
4429
+ );
4430
+ }
4431
+
4432
+ void expectThreeLine () {
4433
+ expect (
4434
+ tester.getRect (find.byType (ListTile ).at (0 )),
4435
+ const Rect .fromLTWH (0.0 , 0.0 , 800.0 , height),
4436
+ );
4437
+ expect (
4438
+ tester.getRect (find.byType (CircleAvatar ).at (0 )),
4439
+ const Rect .fromLTWH (16.0 , 8.0 , 40.0 , 40.0 ),
4440
+ );
4441
+ expect (
4442
+ tester.getRect (find.byType (Placeholder ).at (0 )),
4443
+ const Rect .fromLTWH (800.0 - 24.0 - 24.0 , 8.0 , 24.0 , 24.0 ),
4444
+ );
4445
+ expect (
4446
+ tester.getRect (find.byType (ListTile ).at (1 )),
4447
+ const Rect .fromLTWH (0.0 , height, 800.0 , 88.0 ),
4448
+ );
4449
+ expect (
4450
+ tester.getRect (find.byType (CircleAvatar ).at (1 )),
4451
+ const Rect .fromLTWH (16.0 , height + 8.0 , 40.0 , 40.0 ),
4452
+ );
4453
+ expect (
4454
+ tester.getRect (find.byType (Placeholder ).at (1 )),
4455
+ const Rect .fromLTWH (800.0 - 24.0 - 24.0 , height + 8.0 , 24.0 , 24.0 ),
4456
+ );
4457
+ }
4458
+
4459
+ await tester.pumpWidget (buildFrame ());
4460
+ expectTwoLine ();
4461
+
4462
+ await tester.pumpWidget (buildFrame (themeDataIsThreeLine: true ));
4463
+ expectThreeLine ();
4464
+
4465
+ await tester.pumpWidget (buildFrame (themeDataIsThreeLine: false , themeIsThreeLine: true ));
4466
+ expectThreeLine ();
4467
+
4468
+ await tester.pumpWidget (buildFrame (themeDataIsThreeLine: true , themeIsThreeLine: false ));
4469
+ expectTwoLine ();
4470
+
4471
+ await tester.pumpWidget (buildFrame (isThreeLine: true ));
4472
+ expectThreeLine ();
4473
+
4474
+ await tester.pumpWidget (buildFrame (themeIsThreeLine: true , isThreeLine: false ));
4475
+ expectTwoLine ();
4476
+
4477
+ await tester.pumpWidget (buildFrame (themeDataIsThreeLine: true , isThreeLine: false ));
4478
+ expectTwoLine ();
4479
+
4480
+ await tester.pumpWidget (
4481
+ buildFrame (themeDataIsThreeLine: true , themeIsThreeLine: true , isThreeLine: false ),
4482
+ );
4483
+ expectTwoLine ();
4484
+
4485
+ await tester.pumpWidget (buildFrame (themeIsThreeLine: false , isThreeLine: true ));
4486
+ expectThreeLine ();
4487
+
4488
+ await tester.pumpWidget (buildFrame (themeDataIsThreeLine: false , isThreeLine: true ));
4489
+ expectThreeLine ();
4490
+
4491
+ await tester.pumpWidget (
4492
+ buildFrame (themeDataIsThreeLine: false , themeIsThreeLine: false , isThreeLine: true ),
4493
+ );
4494
+ expectThreeLine ();
4495
+ });
4364
4496
}
4365
4497
4366
4498
RenderParagraph _getTextRenderObject (WidgetTester tester, String text) {
0 commit comments