provide_deprecation_message
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:
dart
@deprecated
void oldFunction(arg1, arg2) {}
GOOD:
dart
@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:
analysis_options.yaml
yaml
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:
analysis_options.yaml
yaml
linter:
rules:
provide_deprecation_message: true
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-03-07. View source or report an issue.