目次

provide_deprecation_message

@Deprecated("message") を使用して、非推奨メッセージを指定します。

このルールは、Dart 2.2 から利用可能です。

ルールセット: core推奨flutter

詳細

#

必ず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