sendPlatformMessage method

  1. @Deprecated('Use WidgetTester.platformDispatcher.sendPlatformMessage(name, data, callback) instead. ' 'Deprecated to prepare for the upcoming multi-window support. ' 'This feature was deprecated after v3.9.0-0.1.pre.')
  2. @override
void sendPlatformMessage(
  1. String name,
  2. ByteData? data,
  3. PlatformMessageResponseCallback? callback
)
override

Sends a message to a platform-specific plugin.

Calling this function forwards the call to the same function on the PlatformDispatcher singleton, so instead of calling it here, you should consider calling it on WidgetsBinding.instance.platformDispatcher instead (or, when WidgetsBinding isn't available, on PlatformDispatcher.instance). The reason this function forwards to the PlatformDispatcher is to provide convenience for applications that only use a single main window.

The name parameter determines which plugin receives the message. The data parameter contains the message payload and is typically UTF-8 encoded JSON but can be arbitrary data. If the plugin replies to the message, callback will be called with the response.

The framework invokes callback in the same zone in which this method was called.

Implementation

@Deprecated(
  'Use WidgetTester.platformDispatcher.sendPlatformMessage(name, data, callback) instead. '
  'Deprecated to prepare for the upcoming multi-window support. '
  'This feature was deprecated after v3.9.0-0.1.pre.'
)
@override
void sendPlatformMessage(
  String name,
  ByteData? data,
  PlatformMessageResponseCallback? callback,
) {
  platformDispatcher.sendPlatformMessage(name, data, callback);
}