skip to Main Content

why the working code is highlighted
enter image description here

3

Answers


  1. If you are using the newest version of Flutter, the new keyword is not needed. Other reasons you could be getting this error:

    • You need to put a const keyword in front of widgets whose data is constant. Example: const EdgeInsets.all(20) instead of just the EdgeInsets.all(20).

    • You need to sort the child property for widgets last. It can’t be above any other property (don’t think this is your problem).

    • You need to add a Key to widgets (this appears to be your problem for the underline under App). Check my answer here for what to do.

    Login or Signup to reply.
  2. It because your IDE is recommend you to using const on your <widget>.

    Login or Signup to reply.
  3. why the working code is highlighted

    Instead of us guessing what rules your project has enabled to bring up those warning, you could just hover over the highlighted section and your IDE should tell you what is is it thinks is not up to the rules of your project.

    There should also be a list available in an extra window, though I have no idea what that window is called in Visual Studio Code.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search