avoid_web_libraries_in_flutter
Avoid using web-only libraries outside Flutter web plugin packages.
This rule is available as of Dart 2.6.
Rule sets: flutter
Details
#AVOID using web libraries, dart:html
, dart:js
and dart:js_util
in Flutter packages that are not web plugins. These libraries are not supported outside of a web context; functionality that depends on them will fail at runtime in Flutter mobile, and their use is generally discouraged in Flutter web.
Web library access is allowed in:
- plugin packages that declare
web
as a supported context
otherwise, imports of dart:html
, dart:js
and dart:js_util
are disallowed.
Usage
#To enable the avoid_web_libraries_in_flutter
rule, add avoid_web_libraries_in_flutter
under linter > rules in your analysis_options.yaml
file:
linter:
rules:
- avoid_web_libraries_in_flutter
Unless stated otherwise, the documentation on this site reflects Dart 3.6.0. Page last updated on 2024-07-03. View source or report an issue.