injectSrcScript function
Injects a script
with a src
dynamically into the head of the current
document.
Implementation
@visibleForTesting
Future<void> injectSrcScript(String src, String windowVar) async {
ScriptElement script = ScriptElement();
script.type = 'text/javascript';
// script.crossOrigin = 'anonymous';
// script.text = '''
// window.ff_trigger_$windowVar = async (callback) => {
// callback(await import("$src"));
// };
// ''';
script.src = src;
assert(document.head != null);
document.head!.append(script);
// Completer completer = Completer();
// context.callMethod('ff_trigger_$windowVar', [
// (module) {
// context[windowVar] = module;
// context.deleteProperty('ff_trigger_$windowVar');
// completer.complete();
// }
// ]);
// await completer.future;
}