@@ -749,4 +749,67 @@ void main() {
749749 lessThan (initialPadding),
750750 );
751751 });
752+
753+ testWidgets ('Fades and animates insets on scroll if search field starts out collapsed' , (
754+ WidgetTester tester,
755+ ) async {
756+ const TextDirection direction = TextDirection .ltr;
757+ const double scrollOffset = 200 ;
758+ await tester.pumpWidget (
759+ const Directionality (
760+ textDirection: direction,
761+ child: CupertinoApp (
762+ home: CupertinoPageScaffold (
763+ child: CustomScrollView (
764+ slivers: < Widget > [
765+ CupertinoSliverNavigationBar .search (
766+ largeTitle: Text ('Large title' ),
767+ searchField: CupertinoSearchTextField (),
768+ ),
769+ SliverToBoxAdapter (child: SizedBox (height: 1000 )),
770+ ],
771+ ),
772+ ),
773+ ),
774+ ),
775+ );
776+
777+ final Finder searchTextFieldFinder = find.byType (CupertinoSearchTextField );
778+ expect (searchTextFieldFinder, findsOneWidget);
779+
780+ final double searchTextFieldHeight = tester.getSize (searchTextFieldFinder).height;
781+ await tester.tap (find.widgetWithText (CupertinoSearchTextField , 'Search' ), warnIfMissed: false );
782+
783+ final TestGesture scrollGesture1 = await tester.startGesture (
784+ tester.getCenter (find.byType (CustomScrollView )),
785+ );
786+ await scrollGesture1.moveBy (const Offset (0 , - scrollOffset));
787+ await scrollGesture1.up ();
788+ await tester.pumpAndSettle ();
789+
790+ expect (find.text ('Cancel' ), findsOneWidget);
791+ await tester.tap (find.text ('Cancel' ));
792+ await tester.pumpAndSettle ();
793+
794+ final TestGesture scrollGesture2 = await tester.startGesture (
795+ tester.getCenter (find.byType (CustomScrollView )),
796+ );
797+ await scrollGesture2.moveBy (Offset (0 , scrollOffset - searchTextFieldHeight / 2 ));
798+ await scrollGesture2.up ();
799+ await tester.pump ();
800+
801+ final Finder prefixIconFinder = find.descendant (
802+ of: searchTextFieldFinder,
803+ matching: find.byIcon (CupertinoIcons .search),
804+ );
805+
806+ // The prefix icon has faded.
807+ expect (prefixIconFinder, findsOneWidget);
808+ expect (
809+ tester
810+ .widget <Opacity >(find.ancestor (of: prefixIconFinder, matching: find.byType (Opacity )))
811+ .opacity,
812+ lessThan (1.0 ),
813+ );
814+ });
752815}
0 commit comments