Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is package naming convention used in Dart?

Is there a naming convention for Dart packages? Is there maybe a document that describes patterns? I have trouble figuring out naming convention for package names that consist of multiple words. For example, should I use placeView, PlaceView, place_view, or something else?

like image 202
markovuksanovic Avatar asked Jan 28 '14 09:01

markovuksanovic


People also ask

What are naming conventions for a package?

Naming ConventionsPackage names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example, com. example. mypackage for a package named mypackage created by a programmer at example.com .

Can Camelcase have package name?

The package names do not follow camel casing or underscores or hyphens package naming convention.


2 Answers

This is documented on the name section of Pubspec Format documentation.

It should be all lowercase, with underscores to separate words, just_like_this. Stick with basic Latin letters and Arabic digits: [a-z0-9_] and ensure that it’s a valid Dart identifier (i.e. doesn’t start with digits and isn’t a reserved word).

Try to pick a name that is clear, terse, and not already in use.

like image 116
Alexandre Ardhuin Avatar answered Oct 11 '22 13:10

Alexandre Ardhuin


There doesn't seem to be a convention for it, but most of the time, I see lowercase_words_with_underscore being used, both for libraries and packages.

For libraries inside packages, some people also use dots for grouping, for example my_package.lib_1 and my_package.lib_2.

It's all personal preference, I guess.

like image 39
MarioP Avatar answered Oct 11 '22 14:10

MarioP