25

Is it possible to get comments to be placed automatically at the end of a method with Android Studio?

  return new MaterialApp(

    ); // MaterialApp
Pang
  • 9,564
  • 146
  • 81
  • 122
Ricardo Rocha
  • 251
  • 4
  • 6
  • I haven't found the setting that allows to enable that in IntelliJ in Android Studio. I'd suggest to create a feature request in https://youtrack.jetbrains.com/ – Günter Zöchbauer Mar 06 '18 at 12:08
  • I found out that this happens in Visual Studio Code with the flutter plugin and there is called ghost comments. – Ricardo Rocha Mar 08 '18 at 12:25
  • 4
    Yes, it's a dartanalyzer feature, I just didn't find a way to enable it in AS. In IntelliJ there is a checkbox in Preferences > Editor > General > Appearance > Show closing labels in Dart source code – Günter Zöchbauer Mar 08 '18 at 12:30

3 Answers3

64

Closing labels are now supported in Android Studio 3.1 with the latest Dart and Flutter plugin

enter image description here

(last checkbox at the bottom)

Disable checkbox and restart IDE

inaps
  • 1,516
  • 1
  • 9
  • 14
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • 5
    This is such a terrible stress-inducing feature that adds cognitive overhead. So glad I was able to turn it off to clean up my code and now things are easier to read! Brace highlighting should be enough to sort things out. – SacWebDeveloper Feb 20 '19 at 23:29
  • This is now turned on by default, which is awful. – Sava B. Mar 03 '19 at 19:24
5

As in Android Studio 3.4 the location name changes to:

File > Settings... > Editor > General > Appearance

Tick the last checkbox - "Show closing labels in Dart source code".

Wictor Chaves
  • 957
  • 1
  • 13
  • 21
Ruchir Rai
  • 571
  • 5
  • 4
0

Just ctrl + f in settings and paste:

Show closing labels in Dart source code

Disable checkbox and restart the IDE

Now your code is readable!

inaps
  • 1,516
  • 1
  • 9
  • 14