Skip to content
pubscout

import_sorter

4.6.0, released 5 years ago by fluttercommunity.dev

Automatically sorts Dart imports alphabetically and groups them by type

$ flutter pub add import_sorter
Source repository

What it does

Import_sorter reorganizes import statements in Dart files, placing Dart imports first, followed by Flutter, package, and project imports. It can be run from the command line or integrated into CI pipelines.

AI-written summary of version 4.6.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • When you want consistent import ordering across a project
  • During CI to enforce import style
  • When using pre-commit hooks to auto‑format imports

Skip it when

  • When you need a full code formatter like dartfmt or a linter that also handles imports
  • When you prefer manual control over import ordering

Strengths

  • Simple to add as a dev dependency
  • CLI and pre‑commit hooks make integration painless
  • Supports emojis and comment options
  • Works on any Dart project, not just Flutter

Weaknesses

  • Only handles imports, not other formatting
  • Requires manual invocation or CI integration
  • No support for custom grouping beyond the default order

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3

Add import_sorter: ^4.6.0 to dev_dependencies and run `flutter pub run import_sorter:main` or `pub run import_sorter:main`

```bash
flutter pub run import_sorter:main
```

Alternatives

Packages that do the same job and could replace import_sorter.

Works with

Packages commonly used together with import_sorter: ones it builds on, ones built on it, and its own family.