Open tomgilder opened 3 years ago
/cc @goderbauer
/fyi @jonasfj
I am not too familiar with that lint.
@yjbanov Can you say whether that lint is maybe too strict for the web?
I've added a hacky workaround to remove this warning, but you can still see it on previous versions: https://pub.dev/packages/routemaster/versions/0.8.0/score
@pq Do you know why pub.dev warns about avoid_web_libraries_in_flutter
in the first place? I thought scoring is done with score.yaml, which doesn't include this lint?
Honestly I'm confused by that too.
@jonasfj ?
pana used to score using lints from flutter -> https://github.com/flutter/packages/blob/master/packages/flutter_lints/lib/flutter.yaml#L9
I think we should ask flutter if this lint still makes sense.
I think pana now uses https://github.com/dart-lang/lints/blob/main/lib/recommended.yaml
(pana does scoring on pub.dev)
I'm having a similar problem now. Everything worked with routemaster before i added drift package for persistence. If i follow drift docs, i need to run build_web_compilers. But it throws a similar error described in this issue.
[INFO] Running build...
[SEVERE] build_modules:module_library on package:routemaster/src/system_nav_web.dart:
Invalid argument(s): Unsupported conditional import of `dart:html` found in routemaster|lib/src/system_nav_web.dart:
import 'fake_html.dart' if (dart.library.js) 'dart:html';
This environment does not support direct conditional imports of `dart:` libraries. Instead you must create a separate library which unconditionally imports (or exports) the `dart:` library that you want to use, and conditionally import (or export) that library.
[WARNING] build_web_compilers:dart2js_modules on lib/.dart2js.meta_module.raw:
Unable to read module information for package:*, make sure you have a dependency on it in your pubspec.
[INFO] Running build completed, took 967ms
Edit: I realized this is the linter repository. I should probably open an issue in dart-lang/build?
The same problem. Flutter should support both web and native in the same project, so this warning doesn't make sense
Same problem here, I'm adding a wrapper around some calls to see if our app can run on web, and then I ended up into this error. From my point of view, it doesn't make much sense, as the call is conditionally handled under kIsWeb
Same problem here, I'm adding a wrapper around some calls to see if our app can run on web, and then I ended up into this error. From my point of view, it doesn't make much sense, as the call is conditionally handled under kIsWeb
same problem ,du you have any soulution yet
@aike1202 As a workaround, you can just disable this check in linter settings (inside analysis_options.yaml):
linter:
rules:
avoid_web_libraries_in_flutter: false
Describe the issue My package is getting marked down due to
avoid_web_libraries_in_flutter
, and I don't think it should: https://pub.dev/packages/routemaster/score.avoid_web_libraries_in_flutter
disallows import ofdart:html
unless the pubspec.yaml specifies it's a web plugin.My package does support web, and needs to import
dart:html
to access the browser DOM. I don't believe I can specify it's a web plugin in pubspec.yaml as it doesn't have any platform-specific code for the other platforms.I have another production Flutter web app that needs to import
dart:html
, I don't believe this is an edge case.To Reproduce
dart:html
(via conditional exports - e.g.export 'blah_vm.dart' if (dart.library.js) 'blah_web.dart'
)Expected behavior
dart:html
is allowed