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>'.
FAILURE: Build failed with an exception.
flutter pub upgrade --major-versions It's working fine for me. Go to specified class 'BasicMessageChannel' by press and hold ctrl and click on it than search for the 'setMockMessageHandler' by ctrl+F than u will see something like this // Looking for setMockMessageHandler?
Tests using checkMessageHandler have no equivalent in the new API, since message handler registration is handled directly by the ChannelBuffers object, which does not expose the currently registered listener for a channel. (Tests verifying handler registration appear to be rare.) Code that needs migrating may see errors such as the following:
The change outlined in the release notes broke several hundred tests since the mock method handlers were set in the global setUp () for most tests. with code using the default instance of TestDefaultBinaryMessenger: This change allowed me to keep all tests unchanged.
A named channel for communicating with platform plugins using asynchronous message passing. Messages are encoded into binary before being sent, and binary messages received are decoded into Dart values. The MessageCodec used must be compatible with the one used by the platform plugin.
I had the same problem after update plugin's in AndroidStudio on Mac
flutter pub upgrade
did nothing for me, but
flutter clean
flutter pub upgrade --major-versions
has solved the problem
I had the same problem today.
from what i could notice, this basically was a breaking change caused by transition of platform channel test interfaces to flutter_test package.
in my case, the problem was resolved just running the flutter pub upgrade
on a global terminal session.
see more details about the mentioned transition on referred release notes
} but this is just simple hack which is not recommended
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With