The comments are notes that developers can add in source code and are ignored by compilers. It's an art of describing what your code does and may be why. These comments are not evaluated.
It increases the code readability for other developers as well as self that allows to provide information of what tricky things are done within the code for better understanding and maintenance.
In this article, we will look into different types of comments supported by Dart.
The comments in Dart can be done in following different ways:
- Single-line comments
- Multi-line comments
/* ... */
- Single-line Doc comments
- Multi-line Doc comments
/** ... */
Single line comment can be done by
// i.e double slash or double forward slash.
// this is a single-line comment
Multi-line comment also known as block comment. It can be done by
/* ... */.
/* this is a multi-line comment we can also wrap code that is quite useful during debugging or development */
Dart guide suggests us to single-line comment
//. The block comment
(/* ... */) should only be used temporarily to comment out a section of code.
Doc comments also supports Markdown formatting
Single line Doc comment can be done by
/// i.e triple slash or triple forward slash.
You can find usage of it in dart:io library available on GitHub
/// this is a single-line comment
Multi line Doc comment can be done by `/ ... */`**. Below is an example of multi-line Doc comment.
/** * ** Important:** Browser-based apps can't use this library. * Only the following can import and use the dart:io library: * - Servers * - Command-line scripts * - Flutter mobile apps * - Flutter desktop apps */
Read the complete post on our site Dart - Comments
Read others post on our site MeshWorld
Hope you like this!
Keep helping and happy 😄 coding