fluttercommunity / fluttercommunity/import_sorter
Multiline import statements
- Dominant language
- Dart
- Stars
- 183
- Forks
- 42
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When an import statement being splitted in multiple lines (eg. because exceeding the default 80 characters with `show` or `hide` on any long import) the tool moves these lines to the end of the import list. It seems these import statements are not recognized, so they are put in `afterImportLines` [here](https://github.com/fluttercommunity/import_sorter/blob/master/lib/sort.dart#L87).
**To Reproduce**
1. For example add [flutter_local_notifications](https://pub.dev/packages/flutter_local_notifications) as a dependency, as this package will result quite long import lines.
2. Import the package and let's say you want to hide a type (eg. because you have one with the same name in your current file already).
```dart
import 'package:flutter_local_notifications/flutter_local_notifications.dart' hide PendingNotificationRequest;
```
3. After saving (if you have autoformat on) or formatting (eg. with `dart format .` or `flutter format .`) this line is splitted to two, since its length is 110 characters (default and recommended max line length is 80 chars).
```dart
import 'package:flutter_local_notifications/flutter_local_notifications.dart'
hide PendingNotificationRequest;
```
4. When running the import_sorter command, this import line "pair" is moved after all other imports.
**Expected behavior**
Move multiline imports to the section they belong to.
**Meta Information:**
- Dart Version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "windows_x64"
- `import_sorter` Version: 4.4.1
- Is it a Flutter project? Yes
- What version of Flutter are you using (if flutter project): 1.22.5 (channel stable)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.