In the dart documentation it says
For the best performance when developing with the development JavaScript compiler through webdev serve, put implementation files under /lib/src, instead of elsewhere under /lib. Also, avoid imports of package:package_name/src/....
With the "Also, avoid imports of package:package_name/src/...." do they mean other packages? Or do they also mean avoid doing that inside your own package? So do they mean use relative imports with that? Or are they simply referring to the fact that other packages have their src folder reserved for private implementation code which should not be imported. Or both?
From https://dart.dev/tools/pub/package-layout :
You are free to import libraries that live in
lib/src
from within other Dart code in the same package (like other libraries inlib
, scripts inbin
, and tests) but you should never import from another package'slib/src
directory. Those files are not part of the package's public API, and they might change in ways that could break your code.
So to directly answer your questions:
With the "Also, avoid imports of package:package_name/src/...." do they mean other packages?
Yes. You should not depend on another package's private implementation details.
Or do they also mean avoid doing that inside your own package?
Your own package is free to use its own private implementation details however it wants.
So do they mean use relative imports with that?
Whether you want to use relative or package imports to access files in lib/src/
in your own package is unrelated. You can do whatever you want for your own package.
Or are they simply referring to the fact that other packages have their src folder reserved for private implementation code which should not be imported. Or both?
See above.