safeAddScript static method
Implementation
static Future<bool>? safeAddScript(String name, String buffer,
{String? contextCheck}) async {
contextCheck ??= name;
assert(buffer.isNotEmpty == true);
if (hasContext(contextCheck)) return true;
if (!_scriptFetched.containsKey(name)) {
final c = Completer<bool>();
print('AddingScript $name');
_scriptFetched[name] = c.future;
html.document.body!.children.add(script(buffer));
Timer.periodic(Duration(milliseconds: 300), (t) {
if (hasContext(contextCheck!)) {
t.cancel();
c.complete(true);
}
});
}
return _scriptFetched[name]!;
}