-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Consider changing default convention of putting main.dart
inside lib/
or provide guidelines
#15748
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
Comments
That is probably a good idea; having |
I don't understand the problem you are running into. Can you elaborate? What are the two imports that are colliding? |
I have an example project demonstrating the issue here: https://github.com/pulyaevskiy/library-private-issue In case the same Dart file is being imported using both relative and Say, I have a Dart file with a library-level field: // file:lib/a.dart
final a = new A();
class A {} In my project I can import it either with // file:lib/main.dart
import 'a.dart' as relativeA;
import 'package:my_project/a.dart' as packageA;
void main() {
assert(identical(relativeA.a, packageA.a));
/// identical returns `false`, there are two different instances of `a` field.
} I normally use Moving This is just a proposal. This can also be solved with a lint rule detecting relative imports in |
I see such issues very frequently. Either the analyzer and VM need to be changed to recognize such mistakes or as suggested follow pub package conventions by moving entry point files to |
It's worth noting that there may be additional issues with mixing relative and |
FYI: dart-lang/sdk#32601 has been re-opened and it seems like will be addressed on the language level (which would be really great). |
should be covered by dart-lang/sdk#33076 |
I'm closing this as dup of dart-lang/sdk#33076 |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
This is to prevent users from potential bugs caused by dart-lang/sdk#32601.
In my project I have several top-level library files, e.g.:
In the
lib/main.dart
I was using relative imports to these:Which caused a really weird and hard to debug issue.
As mentioned in the linked SDK issue a simple fix would be to replace relative file imports with
package:
imports. However it would be really hard for a new user to debug such issues or even notice that something is wrong as there is nothing that tells "do not use relative imports in lib/main.dart".The text was updated successfully, but these errors were encountered: