I was just commenting my application as i found out that you can use diffrent commenting. I’am curious if there are some commenting rules for this or has it something to do with the auto commenting of flutter it self?
My choice go’s to the ///
one since the color is different so it is better to see what i commented and what flutter did.
This make me wonder why there are two diffrent ways to comment
// <-- This is a way
/// <-- This is a way
Thanks in advance
4
Answers
According to Effective Dart,
//
is for a single-line comment, like you’d have on the inside of a function///
is for multi-line (though single-lines are supported too) documentation comments, like you’d have above a function definition.In Flutter,
//
is used to create a single-line comment, which is ignored by the Dart compiler.///
is used to create a documentation comment, which can be used to generate documentation for your code using thedartdoc
tool. This type of comment is also ignored by the Dart compiler, but it can be used to provide additional information about a class, function, or variable for developers reading the code.Example:
When you use
dartdoc
tool, it will extract the comments from the code and generates the documentation in HTML format.In addition to this refer the official documentation about
dartdoc
guides-documenting-dart-libraries. For the usage and examples refer guides-dartdoc//
is for a single-line comment, like you’d have on the inside of a function///
is for multi-line used to documentation comments, like you’d have above a function definition.Dart supports three kinds of comments:
Also can give you a good hint