{"id":37377951,"url":"https://github.com/aziznal/dart-import-sorter","last_synced_at":"2026-01-16T05:04:32.119Z","repository":{"id":36999341,"uuid":"474910569","full_name":"aziznal/dart-import-sorter","owner":"aziznal","description":"A vscode extension that groups and sorts imports for dart files (https://marketplace.visualstudio.com/items?itemName=aziznal.dart-import-sorter)","archived":false,"fork":false,"pushed_at":"2024-01-09T06:19:33.000Z","size":693,"stargazers_count":15,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-15T05:53:04.495Z","etag":null,"topics":["dart","flutter","import-sort","vscode","vscode-extension"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aziznal.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-03-28T08:23:53.000Z","updated_at":"2024-04-15T05:53:04.495Z","dependencies_parsed_at":"2024-01-09T07:34:44.378Z","dependency_job_id":"4ccc8e65-7e2c-4a21-9826-58fca62cace7","html_url":"https://github.com/aziznal/dart-import-sorter","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/aziznal/dart-import-sorter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziznal%2Fdart-import-sorter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziznal%2Fdart-import-sorter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziznal%2Fdart-import-sorter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziznal%2Fdart-import-sorter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aziznal","download_url":"https://codeload.github.com/aziznal/dart-import-sorter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aziznal%2Fdart-import-sorter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28477210,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T03:13:13.607Z","status":"ssl_error","status_checked_at":"2026-01-16T03:11:47.863Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","flutter","import-sort","vscode","vscode-extension"],"created_at":"2026-01-16T05:04:30.109Z","updated_at":"2026-01-16T05:04:32.105Z","avatar_url":"https://github.com/aziznal.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/aziznal"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n   \u003cimg src=\"icon.png\" width=\"300px\" style=\"margin: auto\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nThis is a VS Code extension that sorts your dart / flutter imports with a single command.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/aziznal/dart-import-sorter/blob/main/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/aziznal/dart-import-sorter\" alt=\"Licence\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://GitHub.com/aziznal/dart-import-sorter/releases/\"\u003e\u003cimg src=\"https://img.shields.io/github/release/aziznal/dart-import-sorter\" alt=\"Release\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/aziznal/dart-import-sorter/actions/workflows/test.yaml\"\u003e\u003cimg src=\"https://github.com/aziznal/dart-import-sorter/actions/workflows/test.yaml/badge.svg\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Usage\n\nThere are three ways to activate the extension:\n\n1. Using the shortcut: `ctrl+alt+o`\n\n2. Using the command palette:\n\n    1. Open the command palette (Ctrl + Shift + P)\n    2. Type and Run `Dart: Sort Imports`\n\n3. Save your active document (with `sortOnSave` set to `true`).\n\n## Features\n\nBy default, this extension will group your dart imports according to source and `package:\u003cnamespace\u003e`.\n\n![Demo](demo/dart-import-sorter-demo.gif)\n\n### Sort On Save\n\nYou can set the extension to sort your dart imports whenever you save your\ncurrent active document. **This is set to `false` by default**, but can be changed in the extension settings.\n\n### Custom Sorting Rules\n\nYou can set your own sorting rules so that imports will be grouped and ordered according to your preference.\n\n#### How it works\n\nThe sorting algorithm only looks at a certain part of the import statement, namely the parts between the quotes. Keep this in mind when writing your own rules.\n\nFor example, the following:\n\n```dart\nimport 'package:something/path/to/import.dart' as something_else;\n```\n\nis simplified to\n\n```dart\n'package:something/path/to/import.dart'\n```\n\nSee the following example:\n\n```jsonc\n// settings.json\n{\n    \"dartimportsorter.matchingRules\": [\n        {\n            \"label\": \"Flutter\",\n            \"regex\": \"^package:flutter.*$\",\n            \"order\": 1,\n            \"regexFlags\": [\"m\"]\n        },\n        {\n            \"label\": \"Dart\",\n            \"regex\": \"^dart:.*$\",\n            \"order\": 2,\n            \"regexFlags\": [\"m\"]\n        },\n        {\n            \"label\": \"Everything else\",\n            \"regex\": \".*\",\n            \"order\": 3,\n            \"regexFlags\": [\"m\"]\n        }\n    ]\n}\n```\n\n#### Default Sorting Rules\n\nThe extension comes with the following default rules:\n\n```json\n[\n    {\n        \"label\": \"Dart\",\n        \"regex\": \"^dart:.*$\",\n        \"order\": 1,\n        \"regexFlags\": [\"m\"]\n    },\n    {\n        \"label\": \"Flutter\",\n        \"regex\": \"^package:flutter/.*$\",\n        \"order\": 10,\n        \"regexFlags\": [\"m\"]\n    },\n    {\n        \"label\": \"Package imports that are NOT your app\",\n        \"regex\": \"^package:(?!\u003capp_name\u003e).*$\",\n        \"order\": 100,\n        \"regexFlags\": [\"m\"]\n    },\n    {\n        \"label\": \"Package imports that ARE your app\",\n        \"regex\": \"^package:\u003capp_name\u003e.*$\",\n        \"order\": 101,\n        \"regexFlags\": [\"m\"]\n    },\n    {\n        \"label\": \"Relative\",\n        \"regex\": \"^\\\\..*$\",\n        \"order\": 1000,\n        \"regexFlags\": [\"m\"]\n    }\n]\n```\n\nYou project name is detected automatically from pubspec.yaml and replaces `\u003capp_name\u003e` when the extension is used. You can use the `\u003capp_name\u003e` placeholder in any custom rules you write.\n\nIf you don't provide custom rules in settings.json, then the extension will use these rules by default. If you provide any configuration whatsoever, then the extension will use only your configuration, completely disregarding the defaults.\n\n### Sorting Within Groups\n\nYou can set the extension to sort your imports within each sorted group according to the following rules:\n\n```json\n[\n    {\n        \"label\": \"Dart\",\n        \"regex\": \"^dart:.*$\",\n        \"regexFlags\": [\"m\"],\n        \"order\": 1\n    },\n    {\n        \"label\": \"Flutter\",\n        \"regex\": \"^package:flutter/.*$\",\n        \"regexFlags\": [\"m\"],\n        \"order\": 10\n    },\n    {\n        \"label\": \"Package imports that are NOT your app\",\n        \"regex\": \"^package:(?!\u003capp_name\u003e).*$\",\n        \"regexFlags\": [\"m\"],\n        \"order\": 100\n    },\n    {\n        \"label\": \"Package imports that ARE your app as well as relative imports\",\n        \"regex\": \"^package:\u003capp_name\u003e.*$|^\\\\..*$\",\n        \"regexFlags\": [\"m\"],\n        \"order\": 101,\n        \"subgroupSortingRules\": [\n            {\n                \"label\": \"Package imports that ARE your app\",\n                \"regex\": \"^package:\u003capp_name\u003e.*$\",\n                \"regexFlags\": [\"m\"],\n                \"order\": 1\n            },\n            {\n                \"label\": \"Relative\",\n                \"regex\": \"^\\\\..*$\",\n                \"regexFlags\": [\"m\"],\n                \"order\": 2\n            }\n        ]\n    }\n]\n```\n\nIn the above example, imports are first grouped together, then sorted within each group according to the `subgroupSortingRules` property.\n\nSince the `subgroupSortingRules` property is only defined for the last group, the other groups imports are sorted alphabetically.\n\nFor the last group, app imports are placed first, then relative imports. More complex sorting rules can be defined for each group.\n\n### Other Settings\n\n```jsonc\n{\n    \"dartimportsorter.leaveEmptyLinesBetweenGroups\": true\n}\n```\n\n---\n\n## Release Notes\n\nSee [Changelog](./CHANGELOG.md)\n\n## Contribution\n\nMake a pull request with your changes to be merged with the `develop` branch as it's what I use for staging. Reference an issue if it's available and add me (@aziznal) as a reviewer. Make sure unit tests pass and we'll get your PR sorted in no time! Oh, and please add unit tests for any new features that may require them.\n\n## If you have any questions, contact me at aziznal.dev@gmail.com\n\n### Note\n\nConfiguration inspired by [this extension (typescript import sorter)](https://github.com/SoominHan/import-sorter)\n\n---\n\n\u003ca href=\"https://www.buymeacoffee.com/aziznal\" target=\"_blank\"\u003e\u003cimg src=\"https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png\" alt=\"Buy Me A Coffee\" style=\"height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faziznal%2Fdart-import-sorter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faziznal%2Fdart-import-sorter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faziznal%2Fdart-import-sorter/lists"}