Dart Syntax: Comments & How to write effectively

Dart Syntax: Comments & How to write effectively

Comments

There are two type of comments

  1. Single line comment

  2. multi line comment

Single line comment

A single line comment is use double forward slash ('//').

// This is a single-line comment in Dart.
var x = 10; // Variable declaration

Multi line comment

A multi line comment is use to slash(/) star(*) star(*) slash(/)
comments start with '/*'
comments end with '*/'

/*
This is a multi-line comment
in Dart.
Multiple lines.
*/
var y = 20; // Another variable declaration

How to write effectively

how can use effectively comment

// This function adds two numbers and returns the result.
int add(int a, int b) {
  return a + b;
}

/* 
This is a multi-line comment.
It explains the purpose of the following code block.
*/
var result = add(5, 10); // Calling the add function
print('Result: $result'); // Printing the result