onPlatformMessage property

  1. @Deprecated('Migrate to ChannelBuffers.setListener instead. ' 'This feature was deprecated after v3.11.0-20.0.pre.')
PlatformMessageCallback? get onPlatformMessage

Deprecated. Migrate to ChannelBuffers.setListener instead.

Called whenever this window receives a message from a platform-specific plugin.

Accessing this value returns the value contained in the PlatformDispatcher singleton, so instead of getting it from here, you should consider getting it from WidgetsBinding.instance.platformDispatcher instead (or, when WidgetsBinding isn't available, from PlatformDispatcher.instance). The reason this value forwards to the PlatformDispatcher is to provide convenience for applications that only use a single main window.

The name parameter determines which plugin sent the message. The data parameter is the payload and is typically UTF-8 encoded JSON but can be arbitrary data.

Message handlers must call the function given in the callback parameter. If the handler does not need to respond, the handler should pass null to the callback.

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

Implementation

@Deprecated(
  'Migrate to ChannelBuffers.setListener instead. '
  'This feature was deprecated after v3.11.0-20.0.pre.',
)
PlatformMessageCallback? get onPlatformMessage => platformDispatcher.onPlatformMessage;
  1. @Deprecated('Migrate to ChannelBuffers.setListener instead. ' 'This feature was deprecated after v3.11.0-20.0.pre.')
set onPlatformMessage (PlatformMessageCallback? callback)

Implementation

@Deprecated(
  'Migrate to ChannelBuffers.setListener instead. '
  'This feature was deprecated after v3.11.0-20.0.pre.',
)
set onPlatformMessage(PlatformMessageCallback? callback) {
  platformDispatcher.onPlatformMessage = callback;
}