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
href
field of an AnchorElement - assigning directly to the
src
field of an EmbedElement, IFrameElement, or ScriptElement - assigning directly to the
srcdoc
field of an IFrameElement - calling the
createFragment
method of Element - calling the
open
method of Window - calling the
setInnerHtml
method of Element - calling the
Element.html
constructor - calling the
DocumentFragment.html
constructor
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。 查看源代码 或 报告问题.