Should I use `package:` import when importing my own package's library in Dart?

Viewed 111

I'm little bit confused about which style of import should I use when importing implementation libraries (code under src/lib) from another libraries (and tests) in my own package?

The docs recommends the opposite options.

In pub docs, it says:

When you use libraries from within your own package, even code in src, you can (and should) still use package: to import them.

But in "Effective Dart", it says:

When referencing a library inside your package’s lib directory from another library in that same package, use a relative URI, not an explicit package: URI.

In the end, which style should I use in such cases:

  • import implementation library (under lib/src/) from with public library (under just lib/)?
  • import implementation library (lib/src/foo.dart) from within its test (test/src(?)/foo_test.dart)?
  • import public library (lib/foo.dart) from within its test (test/foo_test.dart)?
0 Answers
Related