Reputation: 195
I have switched from vsCode to android studio for my flutter project as I think I feel comfortable reading the code In android studio
Though in vs code when i save the file the file gets formatted and it adds const
keyword wherever my widget needed it
PROBLEM
In android studio neither the code gets formatted nor it adds const keyword wherever its needed
Please help with the 2 problem
Upvotes: 5
Views: 5270
Reputation: 427
You must follow these steps :-
1- Go to File
Settings
Languages & Frameworks
Flutter
2- check the Format code on save and Organize imports on save options and Apply changes.
4- running the following command:dart fix --apply
5- res =>
after
before
Upvotes: 1
Reputation: 386
As of my knowledge we have to manually add const keyword where we want...
Upvotes: 1
Reputation: 603
File
-> Settings
-> Languages & Frameworks
-> Flutter
Format code on save
and Organize imports on save
options and Apply changes.Upvotes: 8
Reputation: 11
You can use macros for formatting and saving the document with just one shortcut
Record the macro
BIND THE MICRO WITH SHORTCUT
In the Settings/Preferences dialog ⌘,,
select Keymap.Expand the Macros node and select the created Reformat and Save macro.
Right-click the macro and choose Add Keyboard Shortcut in the context menu
Upvotes: 1