How to make Comments in Flutter & Dart

Last updated on January 7, 2021 The Frog Loading... Post a comment

This is a concise article about commenting in Flutter and Dart.

Single-Line Comment (Format Comment)

Just put two slash symbols at the beginning of the line you want to comment out.

// This is a comment

Multi-Line Comment (Block Comment)


/* ... */

This method is usually used to comment out a block of code, like this:

class HomeScreen extends StatelessWidget {
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(''),
      body: Center(),

DOC Comment

Using DOC comment allows the dartdoc library to automatically generate documentation for your code based on the content of your comments.


/// Deletes the file at [path].
/// Throws an [IOError] if the file could not be found. 

Using hot keys in Visual Studio Code

If you are using Visual Studio Code, you can comment out a single line or a block of code by using keyboard shortcuts. Just select the lines you want to make comment with your mouse, then press the following key combination:

  • Ctrl + K then press Ctrl + C if you’re using Windows
  • Command + K then press Command + C if you’re on a Mac

To uncomment a block of code, use your mouse to select it and then use the following key combination:

  • Ctrl + K then Ctrl + U if you’re on Windows
  • Command + K then Command + U if you’re on a Mac


That’s it. To learn more about Flutter and Dart, check also:

Notify of
Inline Feedbacks
View all comments

Related Articles