unsafe_html
Avoid unsafe HTML APIs.
此规则已从最新的 Dart 版本中移除。
详情
#NOTE: This lint is deprecated and will be removed in a future release. Remove all inclusions of this lint from your analysis options.
AVOID
- assigning directly to the
hreffield of an AnchorElement - assigning directly to the
srcfield of an EmbedElement, IFrameElement, or ScriptElement - assigning directly to the
srcdocfield of an IFrameElement - calling the
createFragmentmethod of Element - calling the
openmethod of Window - calling the
setInnerHtmlmethod of Element - calling the
Element.htmlconstructor - calling the
DocumentFragment.htmlconstructor
BAD:
dart
var script = ScriptElement()..src = 'foo.js';This rule has been removed.
使用方法
#要启用 unsafe_html 规则,请在你的 analysis_options.yaml 文件中,在 linter > rules 下添加 unsafe_html :
analysis_options.yaml
yaml
linter:
rules:
- unsafe_html除非另有说明,否则本网站上的文档反映的是 Dart 3.6.0。页面最后更新于 2025-02-05。 查看源代码 或 报告问题.