embedWebIframeJsConnector static method
(WEB ONLY): Embeds a js-to-dart connector in the HTML source, allowing us to talk to js on web.
Will embed an individual connector for each iframe (if more than 1) on the same screen, using a little trick to disambiguate which connector belongs to which iframe.
This (also the buildIframeViewType function) was needed because, without it, you can still show up multiple iframes, but you can only call JS functions on the last one of them. This is because the last one that renders on the screen will also call latter iframes' "connect_js_to_flutter" callbacks, thus messing up others' functions and, well, everything.
Implementation
static String embedWebIframeJsConnector(
String source, String windowDisambiguator) {
return embedJsInHtmlSource(
source,
{
'parent.$jsToDartConnectorFN$windowDisambiguator && parent.$jsToDartConnectorFN$windowDisambiguator(window)'
},
position: EmbedPosition.aboveHeadCloseTag,
);
}