Flutter: IntelliJ doesn't update after "flutter pub run build_runner build"

Answered

In Flutter, you can generate files "flutter pub run build_runner build". For me, IntelliJ recognizes such changed files, but not their content. I have to close and re-open the project to do this.

Here's an example. I have a "s_caption.dart" file and generated two more files from it: "s_caption.freezed.dart" and "s_caption.g.dart". As you can see in the video below, I can browse these files in IntelliJ and find the types/methods IntelliJ complains about ("_$SCaption", "_SCaption", and "_$SCaptionFromJson"). Yet, the red squiggly lines remain. Only closing and re-opening the project makes them go away. This sucks because it stops the app, takes at least a minute, and I have to reposition all my windows (I have a total of four screens).

Video: https://www.screencast.com/t/ixhkP9u3R 

The build options from the "Build" menu don't work for me because they require a Java SDK defined (which Flutter doesn't have). So, how do I get IntelliJ to recognize the generated files properly? 

I use IntelliJ IDEA 2020.3.1 (Ultimate Edition), build #IU-203.6682.168, built on December 29, 2020. It runs with the JetBrains JDK 11.0.9.1+11-b1207.1 x86_64. My Mac runs Big Sur 11.1. I use the latest plugins for Flutter (52.2.5) and Dart (203.6912).

1
2 comments

I did. Thank you for finding the right issue!

0

Please sign in to leave a comment.