Comments In Dart

Comments In Dart

Comments are the set of statements that are ignored by the Dart compiler during the program execution.

Types of Comments

Dart provides three kinds of comments

  • Single-line Comments

  • Multi-line Comments

  • Documentation Comments

Single-line Comment

We can apply comments on a single line by using the // (double-slash). The single-line comments can be applied until a line break.

eg:-

void main(){
// This will print the given statement on screen
print("Welcome to JavaTpoint");
}

Multi-line Comment

Sometimes we need to apply comments on multiple lines; then, it can be done by using /*…..*/. The compiler ignores anything that written inside the /*…*/, but it cannot be nested with the multi-line comments. Let's see the following example.

void main(){
/ This is the example of multi-line comment This will print the given statement on screen /

print("Welcome to JavaTpoint");
}

Dart Documentation Comment

The document comments are used to generate documentation or reference for a project/software package. It can be a single-line or multi-line comment that starts with /// or /*. We can use /// on consecutive lines, which is the same as the multiline comment. These lines ignore by the Dart compiler expect those which are written inside the curly brackets. We can define classes, functions, parameters, and variables. Consider the following example

eg:-

void main(){
///This is
///the example of
///multi-line comment
///This will print the given statement on screen.

print("Welcome to JavaTpoint");
}

THANKYOU!