Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactoring in VSCode with Dart not working

I just started working with flutter and I am unable to refactor dart/flutter in VSCode.

I am running VSCode on MacOSX and installed VSCode as per the flutter documentation, installed the dart and flutter plugins. flutter doctor shows no issues.

The app I am creating runs fine on simulator and devices.

When trying to rename a property, using the refactor shortcut, no option to rename is available. When trying to rename a class, I get 'No refactorings available'

I can't believe this kind of refactoring would not be available.

What am I missing in my setup? Any suggestions on what I can check, change in VSCode?

like image 538
McDJ Avatar asked Jun 20 '19 08:06

McDJ


People also ask

How do I enable refactoring in VS code?

Code Actions = Quick Fixes and refactoringsClicking on the Code Action lightbulb or using the Quick Fix command Ctrl+. will display Quick Fixes and refactorings. If you'd just like to see refactorings without Quick Fixes, you can use the Refactor command (Ctrl+Shift+R).

How do you refactor a flutter code in Vscode?

Ctrl + . in Code opens the “lightbulb” menu showing all code fixes/refactors.

How do you test a Dart code in Vscode?

To run a Dart console application: Install the Code Runner Extension. Open the Dart code file in Text Editor, then use shortcut Ctrl+Alt+N , or right click the Text Editor and then click Run Code in context menu, the Dart console application will run and the output will be shown in the Output Window.

Is visual studio used for refactoring the code?

Visual Studio provides several tools to help you write, edit, and refactor your code.


1 Answers

If you mean refactorings like Wrap with Container, press Ctrl+.

Earlier button called "Refactor" in context menu was available, but it isn't now, and Ctrl+Shift+R doesn't help. So you can use my advice.

Also reinstalling VSCode helped me to get back the "Refactor" button to the context menu

like image 67
mark Avatar answered Sep 18 '22 23:09

mark