Comments in Dart

Comments

Comments are the set of statements that are ignored by the dart compiler during program execution. They are only used to explain the code to humans so that the user can understand the code in a better way.

Advantages Of Comments

  • You can describe your code.
  • Other people will understand your code more clearly.

Types Of Comments

  • Single-Line Comment: For commenting on a single line of code. E.g. // This is a single-line comment.
  • Multi-Line Comment: For commenting on multiple lines of code. E.g. /* This is a multi-line comment. */
  • Documentation Comment: For generating documentation or reference for a project/software package. E.g. /// This is a documentation comment

Single-Line Comment In Dart

Single line comments start with // in dart. You can write // and your comment.

void main() {
// This is single-line comment.
print("Welcome to Technology Channel.");
}
Show Output

Multi-Line Comment In Dart

Multi line comments start with /* and end with */ . You can write your comment inside /* and */.

void main(){  
/*
This is multi-line comments.
*/
    print("Welcome to Technology Channel.");  
}  
Show Output

Documentation Comment In Dart

Documentation comments are helpful when you are writing documentation for your code. Documentation comments start with /// in dart.

void main(){  
/// This is documentation comment
    print("Welcome to Technology Channel.");  
}  
Show Output