unsafe_html
Avoid unsafe HTML APIs.
This rule is available as of Dart 2.4.0.
Details
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:
var script = ScriptElement()..src = 'foo.js';
Usage
To enable the unsafe_html rule,
add unsafe_html under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- unsafe_html