Comment in Dart

Find this useful? Support us: Star on GitHub 6
Category: Other | Language: Dart

In Dart, there are two types of comments: single-line comments and multi-line comments.

1. Single-line comments start with two forward slashes '//' and continue to the end of the line. They are used to add comments to a single line of code. For example:

// This is a single-line comment
print('Hello, World!'); // This line will print 'Hello, World!'

2. Multi-line comments start with a forward slash followed by an asterisk '/*' and end with an asterisk followed by a forward slash '*/'. They are used to add comments to multiple lines of code. For example:

/*
This is a multi-line comment.
It can span multiple lines of code.
*/
void main() {
  print('Hello, World!'); // This line will print 'Hello, World!'
}

It is important to add comments to your code to make it more readable and understandable for yourself and others who may review your code.