Dart Comments

Welcome to the tutorial of Dart Comments.

Comments are statements that are ignored by Dart compiler.

You can write comments any where in the program between dart statements.

In this tutorial, we will learn three different types of comments supported by Dart programming language.

  1. Single Line Comments
  2. Block (Multi-line) Comments
  3. Documentation Comments

Single Line Comments

To write single line comments, use double forward slash // and then write your comment after that in the same line.

void main(){
	//this is comment
	//this is another comment
}
ADVERTISEMENT

Block (Multi-Line) Comments

You can write multiple line comments enclosed between /* and */. Following is an example of how to write block comments.

Dart Program

void main(){
	/*
	This is a block comment.
	It can contain multiple lines as comment.
	Another line in this block comment.
	*/
}

Documentation Comments

These comments are similar to single line comments. But are specially treated by IDEs and dartdoc libraries. You can use these documentation comments for documenting your classes, methods, etc., in the dart libraries you develop.

Using some documentation preparation tools, you can generate documentation from code automatically.

Dart Program

///Documentation Comments
///Some description about main() method.
void main(){
	
}

Conclusion

In this Dart Tutorial, we learned different types of commenting techniques and how to use them.