什么是Dart中使用的包命名约定?

mar*_*vic 12 dart dart-editor

是否有Dart包的命名约定?是否有可能描述模式的文档?我无法确定包含多个单词的包名称的命名约定.举例来说,我应该使用placeView,PlaceView,place_view,还是别的什么?

Ale*_*uin 12

这在Pubspec格式文档名称部分有记录.

它应该全部小写,用下划线来分隔单词,just_like_this.坚持使用基本的拉丁字母和阿拉伯数字:[a-z0-9_]并确保它是有效的Dart标识符(即不以数字开头且不是保留字).

尝试选择一个清晰,简洁且尚未使用的名称.


Mar*_*ioP 6

似乎没有一个约定,但大多数时候,我看到它lowercase_words_with_underscore被用于库和包。

对于包内的库,有些人还使用点进行分组,例如my_package.lib_1my_package.lib_2

我想这都是个人喜好。


Hem*_*rma 5

只能使用小写字母创建flutter项目,项目名称之间不能有空格,避免添加特殊字符。按照以下步骤操作,您将不会收到此类错误。

"ProjectName" is not a valid Dart package name.


From the [Pubspec format description](https://www.dartlang.org/tools/pub/pubspec.html):

**DO** use `lowercase_with_underscores` for package names.

Package names should be all lowercase, with underscores to separate words,
`just_like_this`.  Use only basic Latin letters and Arabic digits: [a-z0-9_].
Also, make sure the name is a valid Dart identifier -- that it doesn't start
with digits and isn't a reserved word.
Run Code Online (Sandbox Code Playgroud)