How do I create an anonymous JavaScript function/callback with Dart's JS interop?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 19:03:05
Justin Fagnani

Dart closures are automatically converted to JS closures when sent across the border. You can just do this:

ID3.callMethod('loadTags', ["filename.mp3", () {
    var tags = ID3.callMethod('getAllTags', ["filename.mp3"]);
    var artistTag = tags['artist'];
    var titleTag = tags['title'];

    if (artistTag != null) {
      artist.text = artistTag;
    }

    if (titleTag != null) {
      track.text = titleTag;
    }
  },
  new js.JsObject.jsify({'dataReader': id3FileReader})
]);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!