onMessage method

dynamic onMessage(
  1. void listener(
    1. String type,
    2. dynamic data
    )
)

Add a listener to be triggered for each message event.

The MetaMask provider emits this event when it receives some message that the consumer should be notified of. The kind of message is identified by the type string.

RPC subscription updates are a common use case for the message event. For example, if you create a subscription using eth_subscribe, each subscription update will be emitted as a message event with a type of eth_subscription.

Implementation

onMessage(void Function(String type, dynamic data) listener) => on(
    'message',
    (ProviderMessage message) =>
        listener(message.type, convertToDart(message.data)));