provide_deprecation_message
通过 @Deprecated("message")
提供弃用消息。
详情
#务必 在 Deprecated
构造函数中指定弃用消息(包含迁移说明和/或移除计划)。
差
dart
@deprecated
void oldFunction(arg1, arg2) {}
好
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) {}
启用
#要启用 provide_deprecation_message
规则,请在你的 analysis_options.yaml
文件中的 linter > rules 下添加 provide_deprecation_message
analysis_options.yaml
yaml
linter:
rules:
- provide_deprecation_message
如果你正在使用 YAML 映射语法配置 linter 规则,请在 linter > rules 下添加 provide_deprecation_message: true
analysis_options.yaml
yaml
linter:
rules:
provide_deprecation_message: true