How to surround flutter widget in vscode
Just wondering if there is a shortcut or extension in visual studio code to surround a code block - or more specifically highlight the widget name and then surround that widgets children.
Often is the case where I have created, lets say a:
Padding(
padding: EdgeInsets.all(10.0),
child: Container(
...
But then after some writing, i want to surround that Padding
with something else, like a Column
or Row
.
As is, I need to prefix the Padding
with Row( child:
and then scroll down and add the new ),` bracket
Is there not a way to just select the Padding
and then tell vs code that I am going to prefix this so add the bracket for me?
Pretty sure I have seen this in action in IntelliJ
Sure!
Vscode offer a few refactor options, including Wrap with Column
:
Just right-click on a widget and press "Refactor".
Place your cursor in the widget you want to edit and use CTRL + .
shortcut to see the options. Use CMD + .
for MacOS. That will do it.