Add auto-Const in flutter in Android Studio

123
  1. Go to File -> Settings -> Languages & Frameworks -> Flutter
  2. Under Editor Section check the Format code on save and Organize imports on save options and Apply changes.
Share:
123
Abdul raheem
Author by

Abdul raheem

Updated on January 04, 2023

Comments

  • Abdul raheem
    Abdul raheem over 1 year

    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

  • Abdul raheem
    Abdul raheem about 2 years
    Also is there not any way that android studio add const keyword where it is needed, as like vs code does... i will be grateful for that... THANK YOU FOR YOUR HELP & TIME
  • Dulaj Nadawa
    Dulaj Nadawa about 2 years
    As my knowledge, there is no way to automatically add the const keywords in the android studio.
  • Dulaj Nadawa
    Dulaj Nadawa about 2 years
    But you can use dart fix --apply command to fix all analyser issues underlined in the yellow color.
  • Abdul raheem
    Abdul raheem about 2 years
    Yes thank you, though for now it adds const wherever it needs by executing the command you shared💖
  • Dulaj Nadawa
    Dulaj Nadawa about 2 years
    Happy to help you! If you found this answer correct, you can mark the answer as correct.