0

I'm trying to handle the method channel call on the dart side. What I expected to happen when calling a constructor was that the program printed sign in!.

What I get instead is

MissingPluginException(No
implementation found for method signIn on channel method_channel_name)
class SampleMethodController {
  static const MethodChannel channel_ =
      MethodChannel('method_channel_name');

  SampleMethodController() {
    channel_.setMethodCallHandler(eventHandler);
    channel_.invokeMethod('signIn');
  }

  Future<dynamic> eventHandler(MethodCall methodCall) async {
    print('here!');
    switch (methodCall.method) {
      case 'signIn':
        handleSignIn();
        break;
      default:
        throw MissingPluginException('notImplemented');
    }
  }

  void handleSignIn() {
    print('sign in!');
  }
}

Why is that happening?

JRazek
  • 191
  • 2
  • 11
  • Did you create the android side of the method? – stacktrace2234 Jul 06 '22 at 20:28
  • I am on a custom platform that's neither android nor ios, but no. I haven't created a method channel with that name besides what's in the code I've pasted. I would like to bypass the native side somehow and just handle the call in the dart. – JRazek Jul 06 '22 at 20:32

0 Answers0