Skip to content

errors remain after running flutter generate #1970

Closed

Description

@szotp

I'm not sure if this is a problem with DartCode or some kind of analysis daemon.

  1. I have a package that utilizes custom Builder, like r_flutter.
  2. New person joins the team, and downloads git.
  3. When they launch the project in VSCode, the code was not generated yet, so there are errors.
  4. New person runs flutter generate, the command suceeds, but errors are still there.
  5. New person executes "Reload window" and errors disappear.

Similiar issues may also happen after flutter clean or switching branch.

I think it would be ideal if VSCode could handle this automatically: do not perform analysis until files have been generated.

EDIT: as requested I will divide this into 2 issues. The problem here is that error remain after running flutter generate - user needs to reload window to fix this.

Activity

  1. DanTup commented on Sep 5, 2019

    @DanTup
    Member

    I would expect the server to handle this automatically as the new files are generated. Are the errors the result of missing generated code, or missing packages?

    Do you happen to have a small sample I could use to reproduce and test with?

    I think it would be ideal if VSCode could handle this automatically: do not perform analysis until files have been generated.

    I don't think it's possible for the VS Code extension to know that there are files that need to be generated. But even if it did, I don't think it makes sense to remove all language functionality (including things like code completion) due to missing files. You might need to work on your code before you can get the generator to generate the files (for example if you have errors that prevent it).

    I think there should be a better way to fix this that doesn't involve taking any functionality away when the files are missing.

  2. added
    awaiting infoRequires more information from the customer to progress
    on Sep 5, 2019
  3. szotp commented on Sep 5, 2019

    @szotp
    ContributorAuthor

    Here is the sample: generation_sample.zip

    What I had in mind was something similiar to promptToRunPubGet that asks user to run flutter generate, maybe it could be even done in the same operation?

    1. User agrees to download packages.
    2. After packages have been downloaded, DartCode checks if builders: option exists in pubspec.
    3. If it exists, it runs flutter generate and updates the prompt message.
    4. After that it restarts analysis server to hide errors.

    If there are errors preventing generate from working then that's a pity, DartCode should continue working as it currently does.

  4. DanTup commented on Sep 5, 2019

    @DanTup
    Member

    What I had in mind was something similiar to promptToRunPubGet that asks user to run flutter generate,

    I think that's a reasonable idea (though I don't know how easily it can be detected right now - I've never used flutter generate :-)). Could you file a new issue to request that, and we can use this one for investigating why the errors don't go away on their own. I'd prefer to fix that (if we can) before restarting the server, since it would be much faster to not have to reinitialise everything.

    I'll see if I can repro using your sample - thanks!

  5. added and removed
    awaiting infoRequires more information from the customer to progress
    on Sep 5, 2019
  6. added this to the v3.5.0 milestone on Sep 5, 2019
  7. changed the title [-]support for flutter generate[/-] [+]errors remain after running flutter generate[/+] on Sep 5, 2019
  8. szotp commented on Sep 29, 2019

    @szotp
    ContributorAuthor

    Before this gets fixed, is there a way to force dart analyzer to recheck? I'm writing VSCode extension that runs flutter generate by itself and it would be nice to force analyzer to refresh itself.

  9. DanTup commented on Sep 30, 2019

    @DanTup
    Member

    The only way right now is to reload the project (the VS Code Reload Window command) but that will terminate the extension host and restart your extension too.

  10. modified the milestones: v3.5.0, v3.6.0 on Oct 1, 2019
  11. modified the milestones: v3.6.0, v3.7.0 on Oct 17, 2019
  12. modified the milestones: v3.7.0, v3.8.0 on Nov 19, 2019
  13. modified the milestones: v3.8.0, v3.9.0 on Jan 2, 2020
  14. modified the milestones: v3.9.0, On Deck on Mar 11, 2020
  15. modified the milestones: On Deck, v3.10.0 on Apr 9, 2020
  16. DanTup commented on Apr 21, 2020

    @DanTup
    Member

    I had a look at this and can repro. I'm not totally familiar with how this works (the import statement imports a file that's in .dart_tool even though it doesn't specify the full path), but it feels like an analysis server bug so I've opened dart-lang/sdk#41605 for it to be looked at there.

  17. removed this from the v3.10.0 milestone on Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions