メインコンテンツにスキップ

provide_deprecation_message

安定版
コア

@Deprecated("メッセージ") を介して、非推奨メッセージを提供します。

詳細

#

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

代わりに、linter ルールを設定するために YAML マップ構文を使用している場合は、linter > rules の下に provide_deprecation_message: true を追加してください。

analysis_options.yaml
yaml
linter:
  rules:
    provide_deprecation_message: true