@@ -3598,6 +3598,64 @@ void main() {
35983598 );
35993599 }
36003600
3601+ testWidgets ('backgroundColor for horizontal scrolling' , (WidgetTester tester) async {
3602+ await tester.pumpWidget (
3603+ MaterialApp (
3604+ home: Scaffold (
3605+ appBar: AppBar (
3606+ elevation: 0 ,
3607+ backgroundColor: MaterialStateColor .resolveWith ((Set <MaterialState > states) {
3608+ return states.contains (MaterialState .scrolledUnder)
3609+ ? scrolledColor
3610+ : defaultColor;
3611+ }),
3612+ title: const Text ('AppBar' ),
3613+ notificationPredicate: (ScrollNotification notification) {
3614+ // Represents both scroll views below being treated as a
3615+ // single viewport.
3616+ return notification.depth <= 1 ;
3617+ },
3618+ ),
3619+ body: SingleChildScrollView (
3620+ child: SingleChildScrollView (
3621+ scrollDirection: Axis .horizontal,
3622+ child: Container (
3623+ height: 1200 ,
3624+ width: 1200 ,
3625+ color: Colors .teal,
3626+ ),
3627+ ),
3628+ ),
3629+ ),
3630+ )
3631+ );
3632+
3633+ expect (getAppBarBackgroundColor (tester), defaultColor);
3634+ expect (tester.getSize (findAppBarMaterial ()).height, kToolbarHeight);
3635+
3636+ TestGesture gesture = await tester.startGesture (const Offset (50.0 , 400.0 ));
3637+ await gesture.moveBy (const Offset (0.0 , - kToolbarHeight));
3638+ await tester.pump ();
3639+ await gesture.moveBy (const Offset (0.0 , - kToolbarHeight));
3640+ await gesture.up ();
3641+ await tester.pumpAndSettle ();
3642+
3643+ expect (getAppBarBackgroundColor (tester), scrolledColor);
3644+ expect (tester.getSize (findAppBarMaterial ()).height, kToolbarHeight);
3645+
3646+ gesture = await tester.startGesture (const Offset (50.0 , 300.0 ));
3647+ // Scroll horizontally
3648+ await gesture.moveBy (const Offset (- kToolbarHeight, 0.0 ));
3649+ await tester.pump ();
3650+ await gesture.moveBy (const Offset (- kToolbarHeight, 0.0 ));
3651+ await gesture.up ();
3652+ await tester.pumpAndSettle ();
3653+ // The app bar is still scrolled under vertically, so it should not have
3654+ // changed back in response to horizontal scrolling.
3655+ expect (getAppBarBackgroundColor (tester), scrolledColor);
3656+ expect (tester.getSize (findAppBarMaterial ()).height, kToolbarHeight);
3657+ });
3658+
36013659 testWidgets ('backgroundColor' , (WidgetTester tester) async {
36023660 await tester.pumpWidget (
36033661 buildAppBar (contentHeight: 1200.0 )
0 commit comments