MeshWorld India LogoMeshWorld.
others2 min read

Dart - Comments

Listen to ArticleAI Speech
~2 min read narration
100%
Dart - Comments

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 comments in Dart

Single line comment can be done by // i.e double slash or double forward slash.

// this is a single-line comment

Multi-line comments in Dart

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.

Single-line Doc comments in Dart

Doc comments parsed by dartdoc generates beautiful doc pages from them. A comment is any comment that appears before a declaration is called as Doc comment.

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

library available on GitHub

/// this is a single-line comment

Multi-line Doc comments in Dart

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
  */

Markdown formatting is also supported by Doc comments

Dart guide suggests us to single-line doc comment /// over the multi-line Doc comment (/** ... */).

Hope you find this useful!

Keep helping and happy 😄 coding

Reader Quality Feedback

Did this technical guide help solve your problem?

Suggest Errata ($0)
Vishnu
Primary Author

Vishnu

Founder & Principal Architect at MeshWorld. Senior engineer and instructor specializing in AI agent systems, scalable web architecture, and modern development workflows.

Explore Author Archive
Compute Fuel & Open Testbed
100% Independent & Verified

Fuel High-Density, Zero-Fluff Engineering Deep-Dives

Every guide on MeshWorld is validated on physical Linux nodes and reproducible testbeds. If this article saved you hours of debugging or unblocked production, consider funding our next cluster run.

Weekly Dispatch

Join MeshWorld Dispatch

Get practical tutorials, system blueprints, and curated AI engineering notes straight to your inbox. No fluff, zero spam.

Zero spam. 1-click unsubscribe anytime.Prefer RSS?
Curated Continuations

Up Next in This Domain.

Browse Full Archive