--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Ian Hickson
😸
Thank you, it turns out to be exactly what you've said. main.dart has to import "homepage.dart" and not "package:balh/homepage.dart", and homepage.dart must not import main.dart with the "package" directive neither.Can I put it this way: When importing with the "package" directive Dart perceives it as another "namespace" or "scope" that is different from the one in my application, so that even classes in the imported file will be declared twice?
Finally, are we supposed to always be using relative path to import files locally?
If yes, is there a use case of the "package" directive for local library files?
Honestly I wasn't aware of the difference as the import syntax is generated automatically using the code completion feature of Flutter plugin in Android Studio.
--
Ian Hickson
😸
It depends what you mean by "local". What really matters is that you be consistent. The one key to the problem you were running into is that "main.dart" is imported relatively, not as a package, so for anything in that package you want to be using relative imports.
It depends what you mean by "local", really. In the "flutter" package itself, we use relative paths within a directory to emphasise that they are part of the same layer, but across directories we refer to the other files using the package syntax to be consistent with how people outside the package would do it.
Honestly I wasn't aware of the difference as the import syntax is generated automatically using the code completion feature of Flutter plugin in Android Studio.Ah! That is very good to know. Can you file a bug on that?
Ian Hickson於 2018年3月27日星期二 UTC+8上午4時20分39秒寫道:It depends what you mean by "local". What really matters is that you be consistent. The one key to the problem you were running into is that "main.dart" is imported relatively, not as a package, so for anything in that package you want to be using relative imports.It depends what you mean by "local", really. In the "flutter" package itself, we use relative paths within a directory to emphasise that they are part of the same layer, but across directories we refer to the other files using the package syntax to be consistent with how people outside the package would do it.Just for curiosity, is there any way I could find out that "main.dart" is imported relatively?
Honestly I wasn't aware of the difference as the import syntax is generated automatically using the code completion feature of Flutter plugin in Android Studio.Ah! That is very good to know. Can you file a bug on that?
--
Ian Hickson
😸
@IanThis is why I submitted: https://github.com/flutter/flutter/issues/15748Moving `main.dart` outside of `lib/` would force people to always use `package:` imports and prevent from stepping into this problem again.
--
Ian Hickson
😸