Skip to content

Analysis server sometimes fails to resolve flutter_gen package after running "pub get" #3438

@orestesgaolin

Description

@orestesgaolin

Describe 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:

  1. 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
  2. Run Pub: Get packages in command palette
  3. Try to reference the new package somewhere in the widget tree
  4. Notice it doesn't get imported
  5. Run Pub: Get packages again
  6. Analyzer restarts and after that it looses information about AppLocalizations, running Pub: 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
CleanShot 2021-06-29 at 11 23 33@2x

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    in commandsRelates to commands (usually invoked from the command Palette)is bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions