omit_local_variable_types   
ローカル変数の型注釈を省略します。
詳細
#初期化されたローカル変数に冗長な型注釈を付けないでください。
ローカル変数は、特に関数が小さくなりがちなモダンなコードでは、スコープが非常に限定的です。型を省略することで、読者の注意を、より重要な変数の名前とその初期化された値に集中させることができます。
悪い例
dart
List<List<Ingredient>> possibleDesserts(Set<Ingredient> pantry) {
  List<List<Ingredient>> desserts = <List<Ingredient>>[];
  for (final List<Ingredient> recipe in cookbook) {
    if (pantry.containsAll(recipe)) {
      desserts.add(recipe);
    }
  }
  return desserts;
}良い例
dart
List<List<Ingredient>> possibleDesserts(Set<Ingredient> pantry) {
  var desserts = <List<Ingredient>>[];
  for (final recipe in cookbook) {
    if (pantry.containsAll(recipe)) {
      desserts.add(recipe);
    }
  }
  return desserts;
}推論された型が、変数に持たせたい型ではない場合があります。たとえば、後で他の型の値を代入するつもりである場合などです。その場合は、変数に目的の型を注釈として付けます。
良い例
dart
Widget build(BuildContext context) {
  Widget result = Text('You won!');
  if (applyPadding) {
    result = Padding(padding: EdgeInsets.all(8.0), child: result);
  }
  return result;
}互換性のないルール
#omit_local_variable_types ルールは、以下のルールと互換性がありません。
有効にする
#omit_local_variable_types ルールを有効にするには、analysis_options.yaml ファイルの linter > rules の下に omit_local_variable_types を追加します。
analysis_options.yaml
yaml
linter:
  rules:
    - omit_local_variable_types代わりに、YAML マップ構文を使用して linter ルールを構成している場合は、linter > rules の下に omit_local_variable_types: true を追加します。
analysis_options.yaml
yaml
linter:
  rules:
    omit_local_variable_types: true