Solved: How to group or block a line of codes


Asked by Ariel on December 27, 2021 (source).

I'm working with Flutter and Android Studio. I am trying to block *ahem* Group some line of codes so that I can just hide it by clicking the plus icon on the left hand side.

How to group a line of codes as a single block in Android Studio and/or Flutter?


Question answered by Nibha J (source).

If I am not getting you wrong , you are talking about The Code Folding shortcuts in Android Studio. They allow us to fold Code Blocks & Region Blocks so we can have more fine grained control over what code we are looking at in any given moment. Have you checked these from official page:

Collapse/expand current code block  Control+minus or Control+plus   Command+minus or Command+plus

Collapse/expand all code blocks Control+Shift+minus or Control+Shift+plus   Command+Shift+minus or Command+Shift+plus

For creating a region you can do this simply :

//start region  method
    //your work here

to open this

control+shift+ (plus +)

to close the region:

control+shift+ (minus -)

or Check this :

Video Answers on YouTube