Closed gleich closed 4 years ago
Awesome!
This is really cool. Especially love the emoji support π
As soon as these issues are fixed, the package will get rereviewed and added to the Flutter Community.
@required
and do import 'package:meta/meta.dart';
without having meta
in your dependencies, because meta
is a transitive dependency of flutter
. However, running the tool with this condition removes all meta
imports and creates errors. I was doubting whether this is an actual issue, but transitive dependencies are commonly used, so this tool removing them can be a reason for people to uninstall it (which I wouldn't want because this packages is super sweet).$ flutter pub run import_sorter:main
β
Formatted /lib/app/assets.dart
β
Formatted /lib/app/context.dart
β
Formatted /lib/app/app.dart
β
Formatted /lib/app/theme.dart
β
Formatted /lib/utils.dart
β
Formatted /lib/backend/app_state_store.dart
β
Formatted /lib/backend/backend.dart
β
Formatted /lib/backend/utils/observable.dart
β
Formatted /lib/backend/utils/behaviour_subject.dart
Unhandled exception:
RangeError (index): Invalid value: Not in range 0..11, inclusive: 12
#0 List.[] (dart:core-patch/growable_array.dart:146:60)
#1 sortImports (package:import_sorter/sort.dart:35:14)
#2 main (file:///Users/jeroen/Development/flutter/.pub-cache/hosted/pub.dartlang.org/import_sorter-1.0.7/bin/main.dart:41:38)
#3 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
pub finished with exit code 255
Unfortunately, this project is currently not open source, so I can't give you the code to test it. However, I'll try to see if I can isolate the issue. Hope this error log gives you any clues. Let me know if you want more info.
Please make these changes and tell me when you've done so in this issue. If you have any questions, don't hesitate to ask. ππ»
Best regards.
Thanks! I'll let you know when I've implemented the changes.
Just resolved the issue with transitive dependencies. I now get the list of all the dependencies from pubspec.lock
and it even runs flutter pub get
or pub get
automatically to ensure the pubspec.lock
is up to date!
As far as the error you are getting goes I have no idea why. I tried running it with a similar project and got no error. What it looks like is happening is I am trying to get the value at i + 1
in a for loop. This shouldn't be a problem though because before that I check in an if statement to see if i != lines.length
. Here is the code snippet surround this:
for (int i = 0; i < lines.length; i++) {
// If line is an import line
if (lines[i].startsWith('import ') && lines[i].endsWith(';')) {
if (lines[i].contains('dart:')) {
dartImports.add(lines[i]);
} else if (lines[i].contains('package:flutter/')) {
flutterImports.add(lines[i]);
} else if (lines[i].contains('package:$package_name/') ||
!lines[i].contains('package:')) {
projectImports.add(lines[i]);
}
for (final dependency in dependencies) {
if (lines[i].contains('package:$dependency/') &&
dependency != 'flutter') {
packageImports.add(lines[i]);
}
}
} else if (i != lines.length &&
lines[i].contains('//') &&
lines[i + 1].startsWith('import ') &&
lines[i + 1].endsWith(';')) {
} else if (dartImports.isEmpty &&
flutterImports.isEmpty &&
packageImports.isEmpty &&
projectImports.isEmpty) {
beforeImportLines.add(lines[i]);
} else {
afterImportLines.add(lines[i]);
}
}
Great work!
I have good news, I found the culprit. π
I have a completely commented out class in that project.
// import 'package:cloud_firestore/cloud_firestore.dart';
// import 'package:json_annotation/json_annotation.dart';
// class TimestampConverter implements JsonConverter<DateTime, Timestamp> {
// const TimestampConverter();
// @override
// DateTime fromJson(Timestamp value) => value.toDate();
// @override
// Timestamp toJson(DateTime value) => Timestamp.fromDate(value);
// }
If I remove that, it all formats properly. I hope that fact and the stack trace I gave you helps resolve the error. Let me know if I can do anything else! ππ»
Oh cool. Is there anything else I need to do to move forward with the approval process? Thanks!
The only thing to do is fix the above error, so make sure commented files don't make the tool crash π
Sounds good! Should be done soon
Finished! 1.0.9 fixes the comment issue.
LGTM
Thanks for submitting this package. It has been reviewed and approved for release on the Flutter Community GitHub! π Great work. ππ»
Please follow steps 3 through 7 in the Flutter Community Transfer Guide and let me know when you're done.
Good luck! ππ»
All ready!
Great!
You've just been added as a Flutter Community pub.dev publisher member. Please check your email.
Accept the invite, then go to your package and transfer ownership to fluttercommunity.dev
You have also been invited to be a member of the Flutter Community GitHub organization. After accepting your invitation, please go to your repository's settings and transfer the package to the user/organization fluttercommunity
.
Let me know if you have any questions or need help! ππ»
I am getting a You donβt have the permission to create public repositories on fluttercommunity
error when trying to transfer the repo.
Sorry about that! We recently changed our member permission system. Please try again.
Done! For some reason, I am not able to change the description of the repo. I saw that some other repos had Maintainer: @Matt-Gleich
in their description. Can you please enable that for me? Thanks!
Awesome. That's the next step! Let me fix that for you.
Done! You should have access to maintain anything on the repo now.
Let me know if you have any remaining questions. Thanks for the package! ππ»
Closing this.
Thanks!
PS: Your package will show up on our package table soon. ππ»
Tada~ π
Package Proposal: import_sorter
Dependency name (as used in pubspec.yaml): import_sorter Current pub.dev link: https://pub.dev/packages/import_sorter Current Git repository link: https://github.com/Matt-Gleich/import_sorter Description: Dart package that automatically sorts all your flutter or dart imports Current maintainer: Matthew Gleich, matthewgleich@gmail.com, @Matt-Gleich Needs new maintainer after transfer: NO Reason for transfer: Wanna expose more people to this package as I think it can help a lot of people. Comments: Excited π