Search packages, repositories and app categories

Package detailsv0.0.2

sort_pubspec_dependencies

Dev dart package for sorting dependencies and dev_dependencies in pubspec.yaml

AndroidiOSLinuxmacOSWindows
30-day downloads
114K
Likes
6
Pub points
160

Install package

flutter pub add sort_pubspec_dependencies

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A development tool for automatically sorting dependencies and dev_dependencies in pubspec.yaml files. This package ensures consistent and clean dependency ordering, improving readability and maintainability of Flutter projects. It integrates seamlessly with the Flutter CLI, allowing developers to sort dependencies with a simple command. Ideal for teams enforcing code style standards or maintaining large-scale applications where dependency management is critical.

Use cases

  • Maintaining clean pubspec.yaml files
  • Enforcing consistent dependency order in team projects
  • Automating dependency formatting during CI/CD
  • Improving readability of dependency lists
  • Simplifying merge conflict resolution

Key features

  • Automatic sorting of dependencies
  • Simple CLI integration
  • Supports both dependencies and dev_dependencies
  • Preserves existing structure and comments
  • Compatible with all major platforms

Suitable for

  • Flutter developers
  • Team-based project maintainers
  • CI/CD pipeline integrators
  • Code quality advocates
  • Projects with frequent dependency updates

Considerations

  • May require manual review after sorting if custom formatting is used
  • Not intended for runtime use
  • Does not validate dependency versions
  • Only affects pubspec.yaml file structure
  • Requires Dart SDK 2.15 or higher

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Description

A Dart CLI tool for sorting dependencies in your pubspec.yaml file.

Keep your pubspec.yaml organized by alphabetically sorting dependencies: and dev_dependencies:. This tool ensures better readability and consistency across projects.

Features

  • Sorts dependencies and dev_dependencies alphabetically.
  • Maintains additional metadata for dependencies (e.g., paths, Git URLs and refs, version constraints).
  • CLI support for easy integration into development workflows.
  • The package is implemented exclusively using Dart tools, there are no transitive dependencies.
  • Lightweight and fast.

Installation

Add sort_pubspec_dependencies as a dev dependency in your project:

dev_dependencies:
  sort_pubspec_dependencies: <latest-version>

Usage

Run the tool locally

dart run sort_pubspec_dependencies

Options

You can create a sort_dependencies.yaml config in the root of your project for:

  • Your pubspec.yaml is located outside the main project directory, you can explicitly specify the path to it using the key: pubspecPath
  • If you want to run flutter pub get after sorting, set the value true to the key needRunPubGetAfterSorting

The sort_dependencies.yaml example:

pubspecPath: 'pubspec.yaml'
needRunPugGetAfterSorting: true

Also, you can run the tool via dart run sort_pubspec_dependencies --pubspec-path=<path>/p=<path> --with-run-pub-get to avoid creating a config and get the same effect

Conclution

Feel free to modify this template to suit your preferences or project needs

Also, you can open issues with a description of the problem if you find unexpected behavior

Categories

Source repository

Projects using this package

No data available yet.

Rankings