Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import_js_library is now using getAssetUrl to resolve no_sleep.js. #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions wakelock_plus/lib/src/web_impl/import_js_library.dart
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
}
Expand Down
Loading