loadJs function

Future<void> loadJs(
  1. String filename
)

Implementation

Future<void> loadJs(String filename) async {
  final completer = Completer<void>();
  final scriptUploadLargestFilesLib = ScriptElement();

  scriptUploadLargestFilesLib.type = 'text/javascript';
  scriptUploadLargestFilesLib.onLoad.listen((_) {
    completer.complete();
  });

  /// It's loading the JavaScript file that contains the upload code.
  scriptUploadLargestFilesLib.src = '/$assetsPath/$filename';

  /// It's adding the JavaScript file to the body of the HTML page.
  document.body!.append(scriptUploadLargestFilesLib);
  return completer.future;
}