@@ -55,7 +55,7 @@ void main() {
5555 });
5656
5757 testWidgets ('mocks .push calls' , (tester) async {
58- when (() => navigator.push (any ())).thenAnswer ((_) async {});
58+ when (() => navigator.push < void > (any ())).thenAnswer ((_) async {});
5959
6060 await tester.pumpTest (
6161 navigator: navigator,
@@ -70,7 +70,7 @@ void main() {
7070 });
7171
7272 testWidgets ('mocks .pushNamed calls' , (tester) async {
73- when (() => navigator.pushNamed (any ())).thenAnswer ((_) async {} );
73+ when (() => navigator.pushNamed (any ())).thenAnswer ((_) async => null );
7474
7575 await tester.pumpTest (
7676 navigator: navigator,
@@ -86,7 +86,7 @@ void main() {
8686
8787 testWidgets ('mocks .pushNamedAndRemoveUntil calls' , (tester) async {
8888 when (() => navigator.pushNamedAndRemoveUntil (any (), any ()))
89- .thenAnswer ((_) async {} );
89+ .thenAnswer ((_) async => null );
9090
9191 await tester.pumpTest (
9292 navigator: navigator,
@@ -109,7 +109,8 @@ void main() {
109109 });
110110
111111 testWidgets ('mocks .pushReplacement calls' , (tester) async {
112- when (() => navigator.pushReplacement (any ())).thenAnswer ((_) async {});
112+ when (() => navigator.pushReplacement <void , Object ?>(any ()))
113+ .thenAnswer ((_) async {});
113114
114115 await tester.pumpTest (
115116 navigator: navigator,
@@ -125,7 +126,7 @@ void main() {
125126
126127 testWidgets ('mocks .pushReplacementNamed calls' , (tester) async {
127128 when (() => navigator.pushReplacementNamed (any ()))
128- .thenAnswer ((_) async {} );
129+ .thenAnswer ((_) async => null );
129130
130131 await tester.pumpTest (
131132 navigator: navigator,
@@ -156,7 +157,8 @@ void main() {
156157 });
157158
158159 testWidgets ('mocks .popAndPushNamed calls' , (tester) async {
159- when (() => navigator.popAndPushNamed (any ())).thenAnswer ((_) async {});
160+ when (() => navigator.popAndPushNamed (any ()))
161+ .thenAnswer ((_) async => null );
160162
161163 await tester.pumpTest (
162164 navigator: navigator,
@@ -201,23 +203,38 @@ void main() {
201203 });
202204
203205 testWidgets ('mocks .maybePop calls' , (tester) async {
204- when (() => navigator.maybePop (any <dynamic >()))
206+ when (() => navigator.maybePop ()).thenAnswer ((_) async => true );
207+
208+ await tester.pumpTest (
209+ navigator: navigator,
210+ builder: (context) => TextButton (
211+ onPressed: () => Navigator .of (context).maybePop (),
212+ child: const Text ('Trigger' ),
213+ ),
214+ );
215+
216+ await tester.tap (find.byType (TextButton ));
217+ verify (() => navigator.maybePop ()).called (1 );
218+ });
219+
220+ testWidgets ('mocks .maybePop calls w/result' , (tester) async {
221+ when (() => navigator.maybePop <bool >(any <bool >()))
205222 .thenAnswer ((_) async => true );
206223
207224 await tester.pumpTest (
208225 navigator: navigator,
209226 builder: (context) => TextButton (
210- onPressed: () => Navigator .of (context).maybePop (testRoutePredicate ),
227+ onPressed: () => Navigator .of (context).maybePop (true ),
211228 child: const Text ('Trigger' ),
212229 ),
213230 );
214231
215232 await tester.tap (find.byType (TextButton ));
216- verify (() => navigator.maybePop (testRoutePredicate )).called (1 );
233+ verify (() => navigator.maybePop < bool >( true )).called (1 );
217234 });
218235
219236 testWidgets ('mocks .pushAndRemoveUntil calls' , (tester) async {
220- when (() => navigator.pushAndRemoveUntil (any (), any ()))
237+ when (() => navigator.pushAndRemoveUntil < void > (any (), any ()))
221238 .thenAnswer ((_) async {});
222239
223240 await tester.pumpTest (
@@ -257,7 +274,8 @@ void main() {
257274 });
258275
259276 testWidgets ('mocks .restorablePush calls' , (tester) async {
260- when (() => navigator.restorablePush (any ())).thenReturn (testRouteName);
277+ when (() => navigator.restorablePush <void >(any ()))
278+ .thenReturn (testRouteName);
261279
262280 await tester.pumpTest (
263281 navigator: navigator,
@@ -274,7 +292,7 @@ void main() {
274292 });
275293
276294 testWidgets ('mocks .restorablePushAndRemoveUntil calls' , (tester) async {
277- when (() => navigator.restorablePushAndRemoveUntil (any (), any ()))
295+ when (() => navigator.restorablePushAndRemoveUntil < void > (any (), any ()))
278296 .thenReturn (testRouteName);
279297
280298 await tester.pumpTest (
@@ -341,7 +359,7 @@ void main() {
341359 });
342360
343361 testWidgets ('mocks .restorablePushReplacement calls' , (tester) async {
344- when (() => navigator.restorablePushReplacement (any ()))
362+ when (() => navigator.restorablePushReplacement < void , Object ?> (any ()))
345363 .thenReturn (testRouteName);
346364
347365 await tester.pumpTest (
@@ -379,7 +397,7 @@ void main() {
379397
380398 testWidgets ('mocks .restorableReplace calls' , (tester) async {
381399 when (
382- () => navigator.restorableReplace (
400+ () => navigator.restorableReplace < void > (
383401 oldRoute: any (named: 'oldRoute' ),
384402 newRouteBuilder: any (named: 'newRouteBuilder' ),
385403 ),
@@ -407,7 +425,7 @@ void main() {
407425
408426 testWidgets ('mocks .restorableReplaceRouteBelow calls' , (tester) async {
409427 when (
410- () => navigator.restorableReplaceRouteBelow (
428+ () => navigator.restorableReplaceRouteBelow < void > (
411429 anchorRoute: any (named: 'anchorRoute' ),
412430 newRouteBuilder: any (named: 'newRouteBuilder' ),
413431 ),
0 commit comments