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

avoid_shadowing_type_parameters

安定版
コア

型パラメータのシャドーイングを避ける。

詳細

#

避ける 型パラメータのシャドーイング。

悪い例

dart
class A<T> {
  void fn<T>() {}
}

良い例

dart
class A<T> {
  void fn<U>() {}
}

有効にする

#

avoid_shadowing_type_parameters ルールを有効にするには、analysis_options.yaml ファイルの linter > rules の下に avoid_shadowing_type_parameters を追加してください。

analysis_options.yaml
yaml
linter:
  rules:
    - avoid_shadowing_type_parameters

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

analysis_options.yaml
yaml
linter:
  rules:
    avoid_shadowing_type_parameters: true