@@ -462,10 +462,7 @@ void main() {
462
462
463
463
testWidgets ('scrolling changes visibility' , (tester) async {
464
464
await setupMessageListPage (tester, messageCount: 10 );
465
-
466
465
final scrollController = findMessageListScrollController (tester)! ;
467
-
468
- // Initial state should be not visible, as the message list renders with latest message in view
469
466
check (isButtonVisible (tester)).equals (false );
470
467
471
468
scrollController.jumpTo (- 600 );
@@ -480,41 +477,38 @@ void main() {
480
477
testWidgets ('dimension updates changes visibility' , (tester) async {
481
478
await setupMessageListPage (tester, messageCount: 100 );
482
479
480
+ // Scroll up, to hide the button.
483
481
final scrollController = findMessageListScrollController (tester)! ;
484
-
485
- // Initial state should be not visible, as the message list renders with latest message in view
486
- check (isButtonVisible (tester)).equals (false );
487
-
488
482
scrollController.jumpTo (- 600 );
489
483
await tester.pump ();
490
484
check (isButtonVisible (tester)).equals (true );
491
485
486
+ // Make the view taller, so that the bottom of the list is back in view.
492
487
addTearDown (tester.view.resetPhysicalSize);
493
488
tester.view.physicalSize = const Size (2000 , 40000 );
494
489
await tester.pump ();
495
- // Dimension changes use NotificationListener<ScrollMetricsNotification
496
- // which has a one frame lag. If that ever gets resolved this extra pump
497
- // would ideally be removed
490
+ // ( Dimension changes use NotificationListener<ScrollMetricsNotification>
491
+ // which has a one- frame lag. If that ever gets resolved,
492
+ // this extra pump would ideally be removed.)
498
493
await tester.pump ();
494
+ // Check the button duly disappears again.
499
495
check (isButtonVisible (tester)).equals (false );
500
496
});
501
497
502
- testWidgets ('button functionality ' , (tester) async {
498
+ testWidgets ('button works ' , (tester) async {
503
499
await setupMessageListPage (tester, messageCount: 10 );
504
-
505
500
final scrollController = findMessageListScrollController (tester)! ;
506
-
507
- // Initial state should be not visible, as the message list renders with latest message in view
508
- check (isButtonVisible (tester)).equals (false );
509
-
510
501
scrollController.jumpTo (- 600 );
511
502
await tester.pump ();
512
- check (isButtonVisible (tester)) .equals (true );
503
+ check (scrollController.position.pixels) .equals (- 600 );
513
504
505
+ // Tap button.
514
506
await tester.tap (find.byType (ScrollToBottomButton ));
507
+ // The list scrolls to the end…
515
508
await tester.pumpAndSettle ();
516
- check (isButtonVisible (tester)).equals (false );
517
509
check (scrollController.position.pixels).equals (0 );
510
+ // … and for good measure confirm the button disappeared.
511
+ check (isButtonVisible (tester)).equals (false );
518
512
});
519
513
});
520
514
0 commit comments