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
除非另有说明,否则本网站上的文档反映的是 Dart 3.7.1 版本。页面上次更新于 2025-03-07。 查看源代码 或 报告问题。