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