From 3c3cf162f986929141a9aa603f75bbdfa133ae62 Mon Sep 17 00:00:00 2001 From: Diego Tori Date: Fri, 16 Feb 2024 13:31:12 -0500 Subject: [PATCH] import_js_library is now using getAssetUrl to resolve no_sleep.js. --- .../lib/src/web_impl/import_js_library.dart | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/wakelock_plus/lib/src/web_impl/import_js_library.dart b/wakelock_plus/lib/src/web_impl/import_js_library.dart index aa587ca..17eccc0 100644 --- a/wakelock_plus/lib/src/web_impl/import_js_library.dart +++ b/wakelock_plus/lib/src/web_impl/import_js_library.dart @@ -1,4 +1,5 @@ import 'dart:html' as html; +import 'dart:ui_web' as ui_web; /// This is an implementation of the `import_js_library` plugin that is used /// until that plugin is migrated to null safety. @@ -15,12 +16,12 @@ void importJsLibrary({required String url, String? flutterPluginName}) { } String _libraryUrl(String url, String pluginName) { - if (url.startsWith('./')) { - url = url.replaceFirst('./', ''); - return './assets/packages/$pluginName/$url'; - } - if (url.startsWith('assets/')) { - return './assets/packages/$pluginName/$url'; + if (url.startsWith('./') || url.startsWith('assets/')) { + if (url.startsWith('./')) { + // Remove the current directory from the URL + url = url.replaceFirst('./', ''); + } + return ui_web.assetManager.getAssetUrl('packages/$pluginName/$url'); } else { return url; }