Skip to main content
A single-line comment in Dart is a lexical construct ignored by the Dart compiler, designed to embed non-executable text within the source code. It is initiated by the double forward-slash token (//). During the tokenization phase, the Dart lexical analyzer discards all characters starting from the // token up to the immediate end-of-line (EOL) sequence. Dart recognizes a line feed (\n), a standalone carriage return (\r), or a carriage return followed by a line feed (\r\n) as valid line terminators. Syntax
Inline Placement A single-line comment can be appended to the end of a valid Dart statement. The compiler processes the executable statement and ignores the subsequent comment token along with its trailing text.
Lexical Behavior Because the lexical analyzer terminates the comment at the first line break, single-line comments cannot span multiple physical lines. Furthermore, any additional // tokens placed within an already initiated single-line comment are simply consumed as ignored raw text rather than nested comment tokens.
Tired of Poor Dart Skills? Fix That With Deep Grasping!Learn More