Skip to main content

Comments in Dart

Comments are the set of statements that are ignored by the dart compiler during program execution. They are only used to explain the code to humans so the user can understand it better.

Advantages Of Comments​

  • You can describe your code.
  • Other people will understand your code more clearly.

Types Of Comments​

  • Single-Line Comment: For commenting on a single line of code. E.g. // This is a single-line comment.
  • Multi-Line Comment: For commenting on multiple lines of code. E.g. / This is a multi-line comment. /
  • Documentation Comment: For generating documentation or reference for a project/software package. E.g. /// This is a documentation comment

Single-Line Comment In Dart​

Single line comments start with // in dart. You can write // and your text.

Multi-Line Comment In Dart​

Multi-line comments start with /* and end with */ . You can write your comment inside /* and */.

Documentation Comment In Dart​

Documentation comments are helpful when you are writing documentation for your code. Documentation comments start with /// in dart.