如何从 Dart 中的 Iframe 接收数据?

How to receive data from an Iframe in Dart?

我知道与 iframe 通信的唯一方法是使用 postMessage 方法,如下所示:

iframe.contentWindow.postMessage("my message", window.location.href);

但我想知道如何在对 iframe 进行任何更改后从它接收数据。

在接收者 window 中,当您收到消息时,您会获得与消息一起传递的发件人,您可以将其发回给该发件人。

window.onMessage.listen((e) {
  e.source.postMessage({'somedata': 'xxx'}, '*');
});

另见