Skip to main content

package_prefixed_library_names

The library name is not a dot-separated path prefixed by the package name.

Description

#

The analyzer produces this diagnostic when a library has a name that doesn't follow these guidelines:

  • Prefix all library names with the package name.
  • Make the entry library have the same name as the package.
  • For all other libraries in a package, after the package name add the dot-separated path to the library's Dart file.
  • For libraries under lib, omit the top directory name.

For example, given a package named my_package, here are the library names for various files in the package:

Example

#

Assuming that the file containing the following code is not in a file named special.dart in the lib directory of a package named something (which would be an exception to the rule), the analyzer produces this diagnostic because the name of the library doesn't conform to the guidelines above:

dart
library something.special;

Common fixes

#

Change the name of the library to conform to the guidelines.