- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Comments in Dart Programming
Comments are a set of commands that are ignored by the compiler. They are used in a scenario where you want to attach a note to your code or a section of code so that when you visit it later, you can recall it easily.
The comment statements are usually ignored during the execution of the program.
There are multiple types of comments in Dart, mainly these are −
Single line comments
Multi-line comments
Documentation comments
We will explore all the above document types in this article.
Single Line comments
Single line comments make use of // (double forward slash). They extend up to a new line character.
Syntax
// this is a comment
Example
void main(){ // var x = 10; print("Hello World"); }
Output
Hello World
Multi-line comment
A multi-line comment makes use of /* */. Everything put between the opening /* and the closing */ will be ignored by the compiler.
Syntax
/* Inside comment Also inside comment */
Example
void main(){ /* multi line comment */ print("Hello World"); }
Output
Hello World
Documentation Comment
The documentation comment is used in cases where we are generating reference for a project or software package.
Syntax
/// This /// is /// a /// documentation /// comment