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?
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 .
The package names do not follow camel casing or underscores or hyphens package naming convention.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With