Analysis server sometimes fails to resolve flutter_gen package after running "pub get"
See original GitHub issueDescribe the bug Almost every hour there’s a situation when after getting packages or updating the .arb files the analyzer hangs for a second and then looses information about the Flutter-generated localization files.
This is partially related to #3270 as sometimes this issue occurs after Flutter extension tries to format the file. In this particular case however, it occurred after adding new package.
To Reproduce Steps to reproduce the behavior:
- Open project and add new package in pubspec.yaml
- it may be significant that the package is a local flutter package stored in
./packages/package_name
subdirectory
- it may be significant that the package is a local flutter package stored in
- Run
Pub: Get packages
in command palette - Try to reference the new package somewhere in the widget tree
- Notice it doesn’t get imported
- Run
Pub: Get packages
again - Analyzer restarts and after that it looses information about
AppLocalizations
, runningPub: Get packages
doesn’t help and only way out of that is either restarting analyzer or VS Code entirely
I was able to reproduce it in my project just by removing package from pubspec.yaml
, calling Pub Get Packages
several times, and then adding the package again.
Expected behavior
The package should be available immediately after getting packages for the first time.
The AppLocalizations
should not be lost, as they are still present in the .dart-tool
directory.
Screenshots
Logs
I sent the Dart instrumentation and analysis logs to logs@dartcode.org
Versions (please complete the following information):
[✓] Flutter (Channel stable, 2.2.2, on macOS 11.4 20F71 darwin-x64, locale pl-PL)
• Flutter version 2.2.2 at /Users/dominik/fvm/versions/stable
• Framework revision d79295af24 (3 weeks ago), 2021-06-11 08:56:01 -0700
• Engine revision 91c9fc8fe0
• Dart version 2.13.3
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/dominik/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = /Users/dominik/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] VS Code (version 1.57.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.23.0
[✓] Connected device (3 available)
• SM T500 (mobile) • R9TR105TMWJ • android-arm64 • Android 11 (API 30)
• macOS (desktop) • macos • darwin-x64 • macOS 11.4 20F71 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114
• No issues found!
Issue Analytics
- State:
- Created 2 years ago
- Reactions:16
- Comments:27 (12 by maintainers)
Top GitHub Comments
A hack that works for me - i pinned
.dart_tool/package_config.json
in vscode. Whenever the error happens i just save the file and the errors disappear. No need to reload the windows any longer.Would still be nice if a proper fix would land soon.
Just wanted to update that after recent update of VS Code extension
v3.26.0
and bumping Flutter to2.5.0-5.2.pre
it still happens the same way as before 😕