Skip to main content
A multi-line comment in Dart is a lexical construct that instructs the compiler to ignore all text enclosed within a specific pair of delimiters, allowing for block-level text that spans one or more lines. The syntax begins with a forward slash followed by an asterisk (/*) and terminates with an asterisk followed by a forward slash (*/).
/*
  This is a multi-line comment.
  The Dart compiler ignores everything between the delimiters.
*/
A distinguishing technical feature of Dart’s multi-line comments is that they fully support nesting. The Dart analyzer tracks the depth of the comment blocks, requiring an exact match between the number of opening /* and closing */ tokens to successfully terminate the outer comment. This prevents premature termination errors common in other C-family languages.
/*
  Level 1 comment block begins.
  
  /*
    Level 2 nested comment block.
    The compiler tracks this inner scope.
  */
  
  Level 1 comment block continues and concludes.
*/
Because the parser evaluates the entire comment block as a single whitespace character, multi-line comments can also be placed inline within a single statement without breaking the syntax.
int total = 100 /* inline block comment */ + 50;
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More