setMockMethodCallHandler method

void setMockMethodCallHandler (Future handler(MethodCall call))

Sets a mock callback for intercepting method invocations on this channel.

The given callback will replace the currently registered mock callback for this channel, if any. To remove the mock handler, pass null as the handler argument.

Later calls to invokeMethod will result in a successful result, a PlatformException or a MissingPluginException, determined by how the future returned by the mock callback completes. The codec of this channel is used to encode and decode values and errors.

This is intended for testing. Method calls intercepted in this manner are not sent to platform plugins.


void setMockMethodCallHandler(Future<dynamic> handler(MethodCall call)) {
    handler == null ? null : (ByteData message) => _handleAsMethodCall(message, handler),