The lib
directory of a Dart project is where the main code of the
package is stored. Code living directly under the lib
directory, when not explicitly declared as private with the __
name
convention, is considered the public API of the package, and can be imported via package imports.
When importing code from a lib
directory of a package available in the local file structure, it is recommended to use package imports
instead of relative imports.
This is because relative imports may cause duplicate imports and may lead to confusion.
import 'package:my_package/my_module.dart'; // OK
import '../my_module.dart'; // Noncompliant: duplicate of above