import_sorter
4.6.0, released 5 years ago by fluttercommunity.dev
Automatically sorts Dart imports alphabetically and groups them by type
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.
- import_path_converter
Automatically convert relative and absolute import paths in Dart files.
47Compare - hotreloader
Automatic hot code reloader for Dart projects that applies file changes to the running process.
70Compare - print_remover
Tool to remove all print() and debugPrint() statements from Dart files
51Compare - android_sms_retriever
Flutter plugin to automatically retrieve OTP SMS on Android without SMS permission
45Compare
Works with
Packages commonly used together with import_sorter: ones it builds on, ones built on it, and its own family.
- yamlimport_sorter depends on itA Dart library for parsing YAML documents into Dart data structures.
- argsimport_sorter depends on itLibrary for parsing raw command-line arguments into options and values using GNU and POSIX styles.
- tintimport_sorter depends on itTerminal string styling as an extension on String.