Search code examples
visual-studio-codeflutter

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


Solution

  • Sure!

    Vscode offer a few refactor options, including Wrap with Column:

    enter image description here

    Just right-click on a widget and press "Refactor".