provide_ deprecation_ message
Learn about the provide_deprecation_message linter rule.
Provide a deprecation message, via
@Deprecated("message").
Details
#
DO specify a deprecation message (with
migration instructions and/or a removal schedule) in the
Deprecated constructor.
BAD:
@deprecated
void oldFunction(arg1, arg2) {}
GOOD:
@Deprecated("""
[oldFunction] is being deprecated in favor of [newFunction] (with slightly
different parameters; see [newFunction] for more information). [oldFunction]
will be removed on or after the 4.0.0 release.
""")
void oldFunction(arg1, arg2) {}
Enable
#
To enable the provide_deprecation_message rule,
add provide_deprecation_message
under
linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- provide_deprecation_message
If you're instead using the YAML map syntax to configure
linter rules, add
provide_deprecation_message: true under
linter > rules:
linter:
rules:
provide_deprecation_message: true
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.