@@ -785,4 +785,131 @@ void main() {
785785 expect (fakeRefresh.called, isTrue);
786786 expect (stretchAccepted, isFalse);
787787 });
788+
789+ testWidgets (
790+ 'CustomRefreshIndicator - trigger - both edges - should be shown when dragging from the start or end edge' ,
791+ (WidgetTester tester) async {
792+ final indicatorController = IndicatorController ();
793+ await tester.pumpWidget (
794+ MaterialApp (
795+ home: CustomRefreshIndicator (
796+ controller: indicatorController,
797+ builder: buildWithoutIndicator,
798+ trigger: IndicatorTrigger .bothEdges,
799+ onRefresh: fakeRefresh.instantRefresh,
800+ child: const DefaultList (itemsCount: 1 ),
801+ ),
802+ ),
803+ );
804+
805+ // start edge
806+ await tester.fling (find.text ('1' ), const Offset (0.0 , 300.0 ), 1000.0 );
807+ await tester.pump ();
808+ // finish the scroll animation
809+ await tester.pump (const Duration (seconds: 1 ));
810+
811+ expect (indicatorController.value, greaterThan (0.0 ));
812+ expect (indicatorController.value, lessThanOrEqualTo (1.0 ));
813+ expect (indicatorController.edge, IndicatorEdge .start);
814+ expect (fakeRefresh.called, isTrue);
815+ // finish the indicator
816+ await tester.pump (const Duration (seconds: 1 ));
817+ expect (indicatorController.edge, isNull);
818+ expect (indicatorController.value, equals (0.0 ));
819+
820+ fakeRefresh.reset ();
821+
822+ // end edge
823+ await tester.fling (find.text ('1' ), const Offset (0.0 , - 300.0 ), 1000.0 );
824+ await tester.pump ();
825+ // finish the scroll animation
826+ await tester.pump (const Duration (seconds: 1 ));
827+
828+ expect (indicatorController.value, greaterThan (0.0 ));
829+ expect (indicatorController.value, lessThanOrEqualTo (1.0 ));
830+ expect (indicatorController.edge, IndicatorEdge .end);
831+ expect (fakeRefresh.called, isTrue);
832+
833+ // finish the indicator
834+ await tester.pump (const Duration (seconds: 1 ));
835+ expect (indicatorController.edge, isNull);
836+ expect (indicatorController.value, equals (0.0 ));
837+ });
838+
839+ testWidgets (
840+ 'CustomRefreshIndicator - trigger - end edge - should be shown only when dragging from the end edge' ,
841+ (WidgetTester tester) async {
842+ final indicatorController = IndicatorController ();
843+ await tester.pumpWidget (
844+ MaterialApp (
845+ home: CustomRefreshIndicator (
846+ controller: indicatorController,
847+ builder: buildWithoutIndicator,
848+ trigger: IndicatorTrigger .endEdge,
849+ onRefresh: fakeRefresh.instantRefresh,
850+ child: const DefaultList (itemsCount: 1 ),
851+ ),
852+ ),
853+ );
854+
855+ // start edge
856+ await tester.fling (find.text ('1' ), const Offset (0.0 , 300.0 ), 1000.0 );
857+
858+ expect (indicatorController.value, equals (0.0 ));
859+ expect (fakeRefresh.called, isFalse);
860+
861+ // end edge
862+ await tester.fling (find.text ('1' ), const Offset (0.0 , - 300.0 ), 1000.0 );
863+ await tester.pump ();
864+ // finish the scroll animation
865+ await tester.pump (const Duration (seconds: 1 ));
866+
867+ expect (indicatorController.value, greaterThan (0.0 ));
868+ expect (indicatorController.value, lessThanOrEqualTo (1.0 ));
869+ expect (indicatorController.edge, IndicatorEdge .end);
870+ expect (fakeRefresh.called, isTrue);
871+
872+ // finish the indicator
873+ await tester.pump (const Duration (seconds: 1 ));
874+ expect (indicatorController.edge, isNull);
875+ expect (indicatorController.value, equals (0.0 ));
876+ });
877+
878+ testWidgets (
879+ 'CustomRefreshIndicator - trigger - start edge - should be shown only when dragging from the end edge' ,
880+ (WidgetTester tester) async {
881+ final indicatorController = IndicatorController ();
882+ await tester.pumpWidget (
883+ MaterialApp (
884+ home: CustomRefreshIndicator (
885+ controller: indicatorController,
886+ builder: buildWithoutIndicator,
887+ trigger: IndicatorTrigger .startEdge,
888+ onRefresh: fakeRefresh.instantRefresh,
889+ child: const DefaultList (itemsCount: 1 ),
890+ ),
891+ ),
892+ );
893+
894+ // end edge
895+ await tester.fling (find.text ('1' ), const Offset (0.0 , - 300.0 ), 1000.0 );
896+
897+ expect (indicatorController.value, equals (0.0 ));
898+ expect (fakeRefresh.called, isFalse);
899+
900+ // start edge
901+ await tester.fling (find.text ('1' ), const Offset (0.0 , 300.0 ), 1000.0 );
902+ await tester.pump ();
903+ // finish the scroll animation
904+ await tester.pump (const Duration (seconds: 1 ));
905+
906+ expect (indicatorController.value, greaterThan (0.0 ));
907+ expect (indicatorController.value, lessThanOrEqualTo (1.0 ));
908+ expect (indicatorController.edge, IndicatorEdge .start);
909+ expect (fakeRefresh.called, isTrue);
910+ // finish the indicator
911+ await tester.pump (const Duration (seconds: 1 ));
912+ expect (indicatorController.edge, isNull);
913+ expect (indicatorController.value, equals (0.0 ));
914+ });
788915}
0 commit comments