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
#除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。