provide_deprecation_message
透過 @Deprecated("訊息")
提供棄用訊息。
此規則從 Dart 2.2 開始提供。
詳細資料
#請務必在 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
除非另有說明,否則本網站上的文件反映的是 Dart 3.6.0。頁面最後更新於 2024-07-03。 檢視原始碼 或 回報問題。