After running the Flutter project, I get this error. What can I do to solve it?

Error: The method 'setMockMessageHandler' isn't defined for the class 'BasicMessageChannel<dynamic>'.

I have tried:

flutter pub upgrage

and this is the result:

No dependencies changed.

1 package is discontinued.

76 packages have newer versions incompatible with dependency constraints.
Try `flutter pub outdated` for more information.


flutter clean
flutter pub upgrade --major-versions

did not help

Solution 1: Dinesh

try repairing your cache, it worked for me

flutter pub cache repair