Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adopting directives_ordering and prefer_relative_imports lints #61

Closed

Conversation

domesticmouse
Copy link
Contributor

Based on #57

@esDotDev
Copy link
Contributor

Curious, is prefer_relative_imports now recommended by the flutter team? I know that mixing relative and package can lead to confusion, so we had standardized on package imports.

From my experience, Android Studio can often fail to provide code-hinting when trying to import things using relative import, and refactoring is also more likely to break when you drag a file into a different folder, which is why we ended up settling on package level.

For example, IDE will not return a relative import for me here for some reason:
image

# Conflicts:
#	lib/views/app_title_bar/app_title_bar.dart
@domesticmouse
Copy link
Contributor Author

Curious, is prefer_relative_imports now recommended by the flutter team?

If you look at the state before https://github.com/gskinnerTeam/flutter-folio/pull/57/files you will see that the analyzer did contain prefer-relative-imports: true which wasn't enfoced because it was mis-spelt.

I personally like prefer_relative_imports because it tells me whether it is an in-project reference, or an external dependency. I tie this with directives_ordering to keep everything organised.

As to the IDE returning the wrong suggestion, I'd raise that as a bug against the Dart Tools team, as it's their code that is returning that suggestion. However, I suspect if you accepted the suggestion, the following cleanup suggestion from the tools would convert it into a local path. I didn't hand convert all the imports to relative paths, I just clicked the drop down in VS Code to organise the imports.

If this change isn't right for you, then don't merge this PR =)

@ingmferrer ingmferrer mentioned this pull request Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants