目录

avoid_web_libraries_in_flutter

Avoid using web-only libraries outside Flutter web plugin packages.

此规则自 Dart 2.6 版本起可用。

_规则集:flutter _

详情

#

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.

使用方法

#

要启用 avoid_web_libraries_in_flutter 规则,请在你的 analysis_options.yaml 文件中,在 linter > rules 下添加 avoid_web_libraries_in_flutter

analysis_options.yaml
yaml
linter:
  rules:
    - avoid_web_libraries_in_flutter