'Flutter Test: how to test if navigation was called and changed screen?

I found this:

verify(mockObserver.didPush(any, any));

But since I use null-safety, it says that I can't use the any because it can be null --> The argument type 'Null' can't be assigned to the parameter type 'Route<dynamic>

If I try

verify(mockObserver.didPush(any!, any));

obviously throws exception since it is null.

How to change this small code to null-safety?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source