未调用 IFrameElement EventListener

IFrameElement EventListener not being called

我已将 EventListener 添加到 IFrameElement,但它从未被调用。

监听器定义:

  EventListener eventListener = (e) {
    print("Lisenter clicked.");
  };

IFrameElement 定义:

  var type = 'click';

  IFrameElement element = IFrameElement()
    ..width = (MediaQuery.of(context).size.width - 400).toString()
    ..height = MediaQuery.of(context).size.height.toString()
    ..srcdoc = value
    ..addEventListener(type, eventListener)
    ..style.border = 'none';

  ui.platformViewRegistry.registerViewFactory(
      createdViewId,
          (int viewId) => element);

dispatchEvent 定义:

marker.addListener('click', function() {dispatchEvent(new Event("click"));console.log("woot");});
单击标记时,会在控制台中找到

"woot",但我从未看到 "Listener clicked"。我做错了什么?

我得到以下结果:

    "marker.addListener('click', function() {dispatchEvent(new MouseEvent('click', {view: window, bubbles: true, cancelable: true }));"
        "var o = Object.create(null);"
        "o.id = \"${property.id}\";"
        ""
        "console.log(o);"
        "window.parent.postMessage(o);"
        ""
        "});\n";

然后我在 window:

上附加一个监听器
window.onMessage.listen((onData) {
  // do things
  if (messageEvent.data["id"] == property.id) { }
})