Comments in Dart

Create Free Backend With Appwrite

Comments

Comments are the set of statements that are ignored by the dart compiler during program execution. They are used to explain the code so that you or other people can understand it easily.

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 text.

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

Show Output
Run Online

Multi-Line Comment In Dart

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

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

Show Output
Run Online

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
Run Online

Video

Watch our video on Dart comments.