Flutter pubspec.yaml dependencies の定義順について

Flutter の pubspec.yaml に定義している dependencies の順番は、個人的にはアルファベット順 (A-Z) にしたいという話です。

Flutter

前提条件

flutter create project_name すると pubspec.yaml に以下のような dependencies の定義がされています。

dependencies:
  flutter:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2

Flutter プロジェクトであるためか、最初に flutter: が定義されており、次に cupertino_icons: が定義されています。

プロジェクト作成時点では気にならないと思うのですが、開発を進めるにつれてパッケージが増えていくと dependencies の定義順が個人的に気になってきました。

pubspec.yaml dependencies をアルファベット順へ

pubspec.yaml の dependencies を適当に定義していたものから、アルファベット順へ並び替えて定義した事例は以下のとおりです。

修正前)

dependencies:
  flutter:
    sdk: flutter

  firebase_core: ^0.2.5
  firebase_analytics: ^1.0.4

  cupertino_icons: ^0.1.2

修正後)

dependencies:
  cupertino_icons: ^0.1.2
  firebase_analytics: ^1.0.4
  firebase_core: ^0.2.5
  flutter:
    sdk: flutter

以上、pubspec.yaml 内の dependencies の定義順はアルファベット順 (A-Z) にしたい、現場からお送りしました。