@@ -902,4 +902,107 @@ void main() {
902902 await tester.pump (const Duration (seconds: 1 )); // finish the indicator hide animation
903903 expect (refreshCalled, true );
904904 });
905+
906+ testWidgets ('RefreshIndicator disallows indicator - glow' , (WidgetTester tester) async {
907+ refreshCalled = false ;
908+ bool glowAccepted = true ;
909+ ScrollNotification ? lastNotification;
910+
911+ await tester.pumpWidget (
912+ MaterialApp (
913+ home: RefreshIndicator (
914+ onRefresh: refresh,
915+ child: Builder (
916+ builder: (BuildContext context) {
917+ return NotificationListener <ScrollNotification >(
918+ onNotification: (ScrollNotification notification) {
919+ if (notification is OverscrollNotification
920+ && lastNotification is ! OverscrollNotification ) {
921+ final OverscrollIndicatorNotification confirmationNotification = OverscrollIndicatorNotification (leading: true );
922+ confirmationNotification.dispatch (context);
923+ glowAccepted = confirmationNotification.accepted;
924+ }
925+ lastNotification = notification;
926+ return false ;
927+ },
928+ child: ListView (
929+ physics: const AlwaysScrollableScrollPhysics (),
930+ children: < String > ['A' , 'B' , 'C' , 'D' , 'E' , 'F' ].map <Widget >((String item) {
931+ return SizedBox (
932+ height: 200.0 ,
933+ child: Text (item),
934+ );
935+ }).toList (),
936+ ),
937+ );
938+ }
939+ ),
940+ ),
941+ ),
942+ );
943+
944+ expect (find.byType (StretchingOverscrollIndicator ), findsNothing);
945+ expect (find.byType (GlowingOverscrollIndicator ), findsOneWidget);
946+
947+ await tester.fling (find.text ('A' ), const Offset (0.0 , 300.0 ), 1000.0 );
948+ await tester.pump ();
949+
950+ await tester.pump (const Duration (seconds: 1 )); // finish the scroll animation
951+ await tester.pump (const Duration (seconds: 1 )); // finish the indicator settle animation
952+ await tester.pump (const Duration (seconds: 1 )); // finish the indicator hide animation
953+ expect (refreshCalled, true );
954+ expect (glowAccepted, false );
955+ });
956+
957+ testWidgets ('RefreshIndicator disallows indicator - stretch' , (WidgetTester tester) async {
958+ refreshCalled = false ;
959+ bool stretchAccepted = true ;
960+ ScrollNotification ? lastNotification;
961+
962+ await tester.pumpWidget (
963+ MaterialApp (
964+ theme: ThemeData .light ().copyWith (useMaterial3: true ),
965+ home: RefreshIndicator (
966+ onRefresh: refresh,
967+ child: Builder (
968+ builder: (BuildContext context) {
969+ return NotificationListener <ScrollNotification >(
970+ onNotification: (ScrollNotification notification) {
971+ if (notification is OverscrollNotification
972+ && lastNotification is ! OverscrollNotification ) {
973+ final OverscrollIndicatorNotification confirmationNotification = OverscrollIndicatorNotification (leading: true );
974+ confirmationNotification.dispatch (context);
975+ stretchAccepted = confirmationNotification.accepted;
976+ }
977+ lastNotification = notification;
978+ return false ;
979+ },
980+ child: ListView (
981+ physics: const AlwaysScrollableScrollPhysics (),
982+ children: < String > ['A' , 'B' , 'C' , 'D' , 'E' , 'F' ].map <Widget >((String item) {
983+ return SizedBox (
984+ height: 200.0 ,
985+ child: Text (item),
986+ );
987+ }).toList (),
988+ ),
989+ );
990+ }
991+ ),
992+ ),
993+ ),
994+ );
995+
996+ expect (find.byType (StretchingOverscrollIndicator ), findsOneWidget);
997+ expect (find.byType (GlowingOverscrollIndicator ), findsNothing);
998+
999+ await tester.fling (find.text ('A' ), const Offset (0.0 , 300.0 ), 1000.0 );
1000+ await tester.pump ();
1001+
1002+ await tester.pump (const Duration (seconds: 1 )); // finish the scroll animation
1003+ await tester.pump (const Duration (seconds: 1 )); // finish the indicator settle animation
1004+ await tester.pump (const Duration (seconds: 1 )); // finish the indicator hide animation
1005+ expect (refreshCalled, true );
1006+ expect (stretchAccepted, false );
1007+ });
9051008}
0 commit comments