Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dart Analyzer in Flutter stops suggesting Classes as you type (and doesn't import them) #44321

Open
kovalyovi opened this issue Nov 26, 2020 · 56 comments
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) type-performance Issue relates to performance or code size

Comments

@kovalyovi
Copy link

kovalyovi commented Nov 26, 2020

I am building an app in Flutter and the problem I started facing I described on Stackoverflow

Basically, at some point, as I launch my flutter project, after a couple of minutes the Dart Analyzer stops suggesting autocompletion of the imported classes (widgets), for example when I type Text - it doesn't suggest the Text widget with a description but the IntelliSense still recognizes it once I finish the widget name. The biggest problem though is with imports. If I type something I already created (for example static class ThemeConstants.), it neither suggests the full class name nor it auto-imports that object. The funniest is that when I created a fresh new project, everything works as it should (it suggests import and auto-completion for the object names).

Unfortunately, my project is not shareable but it has 21k lines of code and ~30 dependencies. Everything worked fine until I cleared some cache on the computer (that's the only thing that went differently).

I tried running Dart: Capture Logs command in VS Code and in the project that I just created, I tried capturing the time when I type "Text" and right after entry with the following log

[6:40:56 PM] [Analyzer] [Info] ==> {"id":"93","method":"edit.getAvailableRefactorings","params":{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","length":0,"offset":4504},"clientRequestTime":1606354856878}
[6:40:57 PM] [Analyzer] [Info] <== {"id":"91","result":{"fixes":[{"error":{"severity":"ERROR","type":"COMPILE_TIME_ERROR","location":{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":4501,"length":3,"startLine":107,"startColumn":13},"message":"Undefined name 'Tex'.","correction":"Try correcting the name to one that is defined, or defining the name.","code":"undefined_identifier","url":"https://dart.dev/tools/diagnostic-messages#undefined_identifier","hasFix":true},"fixes":[{"message":"Create class 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","fileStamp":0,"edits":[{"offset":4790,"length":0,"replacement":"\r\n\r\nclass Tex {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":4800},{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":4501}],"length":3,"suggestions":[]}],"id":"dart.fix.create.class"},{"message":"Create getter 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","fileStamp":0,"edits":[{"offset":2001,"length":0,"replacement":"\r\n\r\n  get Tex => null;"}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":2011}],"length":3,"suggestions":[]}],"id":"dart.fix.create.getter"},{"message":"Create local variable 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","fileStamp":0,"edits":[{"offset":2888,"length":0,"replacement":"var Tex;\r\n    "}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":2892},{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":4515}],"length":3,"suggestions":[]}],"id":"dart.fix.create.localVariable"},{"message":"Create mixin 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","fileStamp":0,"edits":[{"offset":4790,"length":0,"replacement":"\r\n\r\nmixin Tex {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":4800},{"file":"D:\\Work\\Flutter\\zzzzz\\lib\\main.dart","offset":4501}],"length"…
[6:40:57 PM] [Analyzer] [Info] <== {"id":"93","result":{"kinds":["EXTRACT_LOCAL_VARIABLE","EXTRACT_METHOD"]}}

it's followed by

[6:40:56 PM] [Analyzer] [Info] <== {"id":"89","result":{"kinds":["EXTRACT_LOCAL_VARIABLE","EXTRACT_METHOD"]}}
[6:40:56 PM] [Analyzer] [Info] <== {"id":"83","result":{"fixes":[]}}
[6:40:56 PM] [Analyzer] [Info] <== {"id":"88","result":{"assists":[]}}
[6:40:56 PM] [Analyzer] [Info] <== {"id":"90","result":{"completion":"Text","change":{"message":"","edits":[],"linkedEditGroups":[]}}}

Whereas the main project Analyzer stopped at this line and didn't do anything with "Text"

[6:42:03 PM] [Analyzer] [Info] <== {"id":"8762","result":{"fixes":[{"error":{"severity":"ERROR","type":"COMPILE_TIME_ERROR","location":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":24506,"length":3,"startLine":414,"startColumn":39},"message":"Undefined name 'Tex'.","correction":"Try correcting the name to one that is defined, or defining the name.","code":"undefined_identifier","url":"https://dart.dev/tools/diagnostic-messages#undefined_identifier","hasFix":true},"fixes":[{"message":"Create class 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","fileStamp":0,"edits":[{"offset":30683,"length":0,"replacement":"\r\n\r\nclass Tex {\n}"}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":30693},{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":24506}],"length":3,"suggestions":[]}],"id":"dart.fix.create.class"},{"message":"Create getter 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","fileStamp":0,"edits":[{"offset":792,"length":0,"replacement":"\r\n\r\n  get Tex => null;"}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":802}],"length":3,"suggestions":[]}],"id":"dart.fix.create.getter"},{"message":"Create local variable 'Tex'","edits":[{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","fileStamp":0,"edits":[{"offset":1475,"length":0,"replacement":"var Tex;\r\n            "}]}],"linkedEditGroups":[{"positions":[{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":1479},{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":24528}],"length":3,"suggestions":[]}],"id":"dart.fix.create.localVariab…
[6:42:03 PM] [Analyzer] [Info] <== {"id":"8764","result":{"kinds":["EXTRACT_LOCAL_VARIABLE","EXTRACT_METHOD"]}}
[6:42:03 PM] [Analyzer] [Info] <== {"id":"8763","result":{"assists":[]}}
[6:42:04 PM] [Analyzer] [Info] <== {"event":"server.status","params":{"analysis":{"isAnalyzing":true}}}
[6:42:04 PM] [Analyzer] [Info] <== {"event":"analysis.errors","params":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","errors":[{"severity":"ERROR","type":"COMPILE_TIME_ERROR","location":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":24506,"length":3,"startLine":414,"startColumn":39},"message":"Undefined name 'Tex'.","correction":"Try correcting the name to one that is defined, or defining the name.","code":"undefined_identifier","url":"https://dart.dev/tools/diagnostic-messages#undefined_identifier","hasFix":true}]}}
[6:42:04 PM] [Analyzer] [Info] <== {"event":"analysis.occurrences","params":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","occurrences":[{"element":{"kind":"CLASS","name":"IntroductionSeeds","location":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":441,"length":17,"startLine":9,"startColumn":7},"flags":0},"offsets":[441,618],"length":17},{"element":{"kind":"CLASS","name":"StatefulWidget","location":{"file":"C:\\src\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","offset":38431,"length":14,"startLine":896,"startColumn":16},"flags":1},"offsets":[467],"length":14},{"element":{"kind":"TOP_LEVEL_VARIABLE","name":"override","location":{"file":"C:\\src\\flutter\\bin\\cache\\pkg\\sky_engine\\lib\\core\\annotations.dart","offset":4627,"length":8,"startLine":114,"startColumn":14},"flags":10,"returnType":"Object"},"offsets":[488,799,1018,30554],"length":8},{"element":{"kind":"CLASS","name":"_IntroductionSeedsState","location":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":580,"length":23,"startLine":14,"startColumn":7},"flags":16},"offsets":[500,541,580],"length":23},{"element":{"kind":"METHOD","name":"createState","location":{"file":"D:\\Work\\Flutter\\addfaith\\lib\\introduction_screens\\introduction_seeds.dart","offset":524,"length":11,"startLine":11,"startColumn":27},"flags":0,"parameters":"()","returnType":"_IntroductionSeedsState"},"offsets":[524],"length":11},{"element":{"kind":"CLASS","name":"State","location":{"file":"C:\\src\\flutter\\packages\\flutter\\lib\\src\\widgets\\framework.dart","offset":46318,"length":5,"startLine":1040,"startColumn":16},"flags":1,"typeParameters":"<T extends StatefulWidget*>"},"offsets":[612],"length":5},{"element":{"kind":"MIXIN","name":"SingleTickerProviderStateMixin","location":{"file":"C:\\src\\flutter\\packages\\flutter\\lib\\src\\widgets\\ticker_provider.dart","offset":3949,"length":30,"startLine":113,"…

I apologize if I'm doing something wrong and wanted to get advice on either how to fix that or where to refer for help.

  • Dart SDK version: 2.10.4 (stable) (Wed Nov 11 13:35:58 2020 +0100) on "windows_x64"
  • Windows 10 Education x64
  • VS Code
@bensal-kb
Copy link

bensal-kb commented Nov 26, 2020

I also have the same issue, Reloading window solves the issue. But the debugging stops and after a while it happens again. This happens in both Android studio as well as VS code. And I wonder this issue is still not posted before.

@lrhn lrhn added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Nov 26, 2020
@srawlins srawlins added analyzer-server P2 A bug or feature request we're likely to work on labels Nov 30, 2020
@Chris1234567899
Copy link

Same here.

No sure if it's connected but since it started around the same time: "hot reloading" freezes frequently now and only terminating the run process seems to help. Super annoying.

@kovalyovi
Copy link
Author

Any updates guys?

@vininalm
Copy link

I also have the same issue.

@dluanoliveira1
Copy link

Same as here, once you reload the VS Code, it does work until you start debugging again.

@kovalyovi
Copy link
Author

Don't forget guys to thumb up the original question to draw more attention to this issue! :)

@kovalyovi
Copy link
Author

I have just noticed that it most often happen when I use Android API 30 x64 device with Google Play services where if I use devices without Google Play on them it works fine.

@tgpsantos
Copy link

tgpsantos commented Dec 17, 2020

It's happening with me for a month now. Could this be a Windows-only issue?

@omerrciftcii
Copy link

I am facing the same problem, there is no problem on Linux platform but when I use windows, the problem arises

@Dharaneshvar
Copy link

I'm facing the same issue in windows. I recently uninstalled visual studio completely and starting using it. Is there any options that need to be changed in settings or use any plugins?

@filly82
Copy link

filly82 commented Jan 8, 2021

same problem here

@kovalyovi
Copy link
Author

Guys, it's been 2 months now and this issue still persists. Any updates?

@utkudenis
Copy link

I have the same problem :(

@imReker
Copy link

imReker commented Feb 1, 2021

Temporary fix:

  1. Open Dart Analysis tool window.
  2. Click Restart Dart Analysis Server button (Red refresh button).

@kovalyovi
Copy link
Author

Temporary fix:

  1. Open Dart Analysis tool window.
  2. Click Restart Dart Analysis Server button (Red refresh button).

Even though it restarts the Dart Analyzer and it starts suggesting the classes as it should, it kills the 'Hot Reload on Save' feature, thus any time I change anything I have to manually hit 'Hot Reload' button which is even worse than manually importing the classes...

@HasanAlyazidi
Copy link

Same super annoying issue

flutter doctor -v

[✓] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19042.746], locale en-US)
• Flutter version 1.22.4 at W:\Development\Configurations\flutter
• Framework revision 1aafb3a8b9 (3 months ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at W:\Development\Configurations\android\sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = W:\Development\Configurations\android\sdk
• ANDROID_SDK_ROOT = W:\Development\Configurations\android\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.

[!] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

[✓] VS Code (version 1.52.1)
• VS Code at C:\Users\UserName\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.19.0

[✓] Connected device (1 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)

! Doctor found issues in 1 category.

Another issue is Flutter and Dart are not detected by Android Studio, also wrong version (currently running Android Studio 4.2 Beta 3)

@EsteveAguilera
Copy link

Same here, and it's really annoying! 😞

@KlausJokisuo
Copy link

Same for me, IntelliJ - Windows 10

@kovalyovi
Copy link
Author

kovalyovi commented Feb 2, 2021

Don't forget to thumb-up the original question to attract more attention 👍

@HasanAlyazidi
Copy link

I deleted Flutter completely then I have installed Flutter v1.22.6, but still the same issue!

This is a productivity-killer issue

@imReker
Copy link

imReker commented Feb 3, 2021

Even though it restarts the Dart Analyzer and it starts suggesting the classes as it should, it kills the 'Hot Reload on Save' feature, thus any time I change anything I have to manually hit 'Hot Reload' button which is even worse than manually importing the classes...

But you can always use shortcut key

@kovalyovi
Copy link
Author

kovalyovi commented Feb 3, 2021

Even though it restarts the Dart Analyzer and it starts suggesting the classes as it should, it kills the 'Hot Reload on Save' feature, thus any time I change anything I have to manually hit 'Hot Reload' button which is even worse than manually importing the classes...

But you can always use shortcut key

In this case, it's more time consuming to press ctrl+r (the shortcut I created) every time I make a change rather than manually import files. If you have to import classes just a couple of times per file, the hot reload is necessary tens or hundreds of times more.

@imReker
Copy link

imReker commented Feb 4, 2021

Even though it restarts the Dart Analyzer and it starts suggesting the classes as it should, it kills the 'Hot Reload on Save' feature, thus any time I change anything I have to manually hit 'Hot Reload' button which is even worse than manually importing the classes...

But you can always use shortcut key

In this case, it's more time consuming to press ctrl+r (the shortcut I created) every time I make a change rather than manually import files. If you have to import classes just a couple of times per file, the hot reload is necessary tens or hundreds of times more.

I don't have this issue, I'm on master channel.

@kovalyovi kovalyovi reopened this Feb 18, 2021
@kovalyovi
Copy link
Author

I don't have this issue, I'm on master channel.

I still have this issue

(accidentally closed the issue, thus I reopened it)

@devoncarew
Copy link
Member

Hi - thanks for all the feedback on this issue. I'm trying to gather a bit more information to help us diagnose the problem. From my understanding, from the first comment, after some period of time code completion stops suggesting types from the imported libraries. Is that correct? Or, is the issue that code completion no longer suggests types from not yet imported libraries (auto-adding the import when you select that completion entry)?

Could one or two people confirm the above issue?

And, could several people post their configuration? I'd like to try to narrow this down to an OS if possible, and determine whether it still happens on recent (beta) versions of Flutter. If people could append to this issue w/ the below template that would be great:

- operating system:
- flutter version:
- IDE in use:
- any other repro steps / info that would help us narrow down and diagnose the issue:

Thanks in advance!

@kovalyovi
Copy link
Author

kovalyovi commented Feb 23, 2021

From my understanding, from the first comment, after some period of time code completion stops suggesting types from the imported libraries. Is that correct? Or, is the issue that code completion no longer suggests types from not yet imported libraries (auto-adding the import when you select that completion entry)?

@devoncarew
The issue is that first, it doesn't suggest auto-importing and auto-completion for the non-imported files, (the ThemeConstants example) and second, it does not suggest autocompletion for the already imported libraries, for example when I want to set mainAxisAlignment for Column, it would suggest to autocomplete the property mainAxisAlignment but as I type the enum itself, MainAxisAlignment... it does not suggest autocompletion for the first part (MainAxisAlignment) but once I've typed it in, it suggests whatever that enum has (spaceBetween, end, etc.). And it's the same way with manually imported classes. In fact, it wouldn't even suggest SingleChildScrollView once it stops suggesting but still recognizes it (obviously) once you manually type it in.

I also wanted to clarify that this issue happens after some period the application is run and/or after I hit Ctrl+F12 (Go to Implementations) on any class and after it waits for 5+ seconds to find all the implementations and I manually hit ESC and do Ctrl+F12 again and it finds it faster. It looks like it first tries to find implementations and takes forever, I 'exit' that search and do it again - it finds those implementations in the respective window but the class autocompletion looks to die somewhere around there.

Can it be because the project is relatively large? ~30k lines of code.

  • operating system: Windows 10 Education
  • flutter version: 1.22.6
  • IDE in use: VS Code 1.53.2
  • any other repro steps / info that would help us narrow down and diagnose the issue: described above...

@HasanAlyazidi
Copy link

I have found that this issue occurs right after running the app on the emulator either from Visual Studio Code or Android Studio.

operating system: Windows 10 20H2
flutter version: 1.22.6
IDE in use: VS Code 1.53.2
any other repro steps / info that would help us narrow down and diagnose the issue: I tried downgrading and reinstalling Flutter = same issue.

Thank you

@tgpsantos
Copy link

tgpsantos commented Mar 3, 2021

operating system: Windows 10
flutter version: 1.22.6
IDE in use: VS Code
any other repro steps / info that would help us narrow down and diagnose the issue: run the app in debug mode (emulator or real device), after a few minutes the suggestions stop to show up

this definitely seems related to Windows OS

@tgpsantos
Copy link

This seems to be fixed in Flutter 2.0 👍 ❤️

@VyMajoris
Copy link

This seems to be fixed in Flutter 2.0 👍 ❤️

Nope.
image

@MarceloRab
Copy link

Same here 😞

@fernandosandrade
Copy link

same here... and this is VERY frustrating

operating system: Windows 10 20H2
flutter version: 2.0.6
dart version: 2.12.3
IDE in use: Android Studio (version 4.1.0)

@vrnvorona
Copy link

Operating system: MacOS Catalina 10.15.7
Flutter: 1.22.6
Dart: 2.10.5
IDE: IntelliJ IDEA 2020.1

For me it was always like this. Classes inside library (file) are autocompleted correctly, but imported are not. It doesn't matter if I import through export, or directly. After I type Class name completely it doesn't show error and IntelliSense works

@andiblas
Copy link

andiblas commented May 14, 2021

After spending a couple of hours dealing with this frustrating issue, wandering in the Dart settings in VSCode i've found this option that i had unchecked.

image

After enabling this option, everything worked fine. Hope it helps 😇

@vrnvorona
Copy link

After spending a couple of hours dealing with this frustrating issue, wandering in the Dart settings in VSCode i've found this option that i had unchecked.

image

After enabling this option, everything worked fine. Hope it helps 😇

Anyone knows if there is similar settings in IntelliJ based IDEs?

@MATTYGILO
Copy link

MATTYGILO commented May 14, 2021

I'm having this problem as well on android studio it seems that all autofill takes ages now. And many times it forgets to import package when pressing enter on the class

@kovalyovi
Copy link
Author

After spending a couple of hours dealing with this frustrating issue, wandering in the Dart settings in VSCode i've found this option that i had unchecked.

image

After enabling this option, everything worked fine. Hope it helps 😇

I have that option turned on and it's still giving me issues. I think it's somewhere deep in Dart Analyzer where it just terminates if either the project size is too big, or it contains some dependencies, or there is something special about the project structure (I have no idea how to troubleshoot that...).

The tricky part is that you have to restart the whole debugging session and it might not even come back.

@devoncarew is there anything else I/we could provide to speed up the resolution of this issue?

@anburocky3
Copy link

anburocky3 commented Jun 14, 2021

I can confirm the problem exists in latest version of dart, flutter & Android studio too (Please check the logs below)

My Environment details

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19042.1052], locale en-IN)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.57.0)
[√] Connected device (3 available)

• No issues found!

Mostly, I experienced it, when typing Future keyword. This might feel helpful.

As a temporary fix, the below methods fix the problem (temp)

  1. Restarting Android Studio by Invalid Caches & Restart

  2. Restarting Dart Analyser

Hoping for a fix :) TIA

@kovalyovi
Copy link
Author

kovalyovi commented Jul 12, 2021

You can switch to IntelliJ, it works perfectly. I'm using IntelliJ IDEA 2021.1.3 (Community Edition)

It's not a solution but a possible workaround for those open to switching dev environments.

@kovalyovi
Copy link
Author

Guys any updates on this one?

@jerryzhoujw
Copy link

jerryzhoujw commented Jul 22, 2021

I was migrating iterator.first to iterator.firstOrNull.

When typing in VSCode,
The auto import not working with import 'package:collection/collection.dart';.
But it works with other imports.

I'm not sure if it related to this issue, or should create a new one.

flutter doctor -v
jerryzhou@Jerrys-MacBook ~/D/c/f/p/r/robo> flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.4 20F71 darwin-x64, locale en-CN)
    • Flutter version 2.2.3 at /Users/jerryzhou/Documents/code/flutter/sdk/flutter
    • Framework revision f4abaa0735 (3 weeks ago), 2021-07-01 12:46:11 -0700
    • Engine revision 241c87ad80
    • Dart version 2.13.4
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc1)
    • Android SDK at /Users/jerryzhou/Library/Android/sdk
    • Platform android-30, build-tools 30.0.0-rc1
    • Java binary at: /Users/jerryzhou/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/192.6392135/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)
    • 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 3.6)
    • Android Studio at /Users/jerryzhou/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/192.6392135/Android Studio.app/Contents
    • Flutter plugin version 45.1.1
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

[✗] Cannot determine if IntelliJ is installed
    ✗ Directory listing failed

[✓] VS Code (version 1.58.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.24.0

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.164

! Doctor found issues in 1 category.

@kovalyovi
Copy link
Author

https://stackoverflow.com/questions/59848513/autocomplete-not-working-correctly-in-android-studio-with-flutter-first-sugges

@venkata-reddy-boya as @anburocky3 suggested the same, it doesn't always work because it terminates the debug session for some, thus it's not a solution.

@mselmanyildirim
Copy link

mselmanyildirim commented Oct 30, 2021

I think it's somewhere deep in Dart Analyzer where it just terminates if either the project size is too big, or it contains some dependencies, or there is something special about the project structure (I have no idea how to troubleshoot that...).

I also experience this very same issue, on several projects with different levels of complexity from simple to medium. In some projects, I have long maps having 10K or 20K lines, but not a complex code architecture. In some of them, I have very few external dependencies such as:

  shared_preferences: '0.5.12+4'
  dropdown_search: '0.4.9'
  audioplayers: '0.17.0'
  path_provider: '1.6.28'
  cupertino_icons: ^1.0.0

I use Android Studio, I prefer using flutter commands (from a terminal inside IDE) rather than hot reload button etc. I usually use a real device rather than the emulator. These details seem to conflict with some of the other reporters here, so they seem irrelevant to the issue. I use Windows 10 though, which may narrow down where we see the issue (I had the same issue on Windows 7 as well).
I have two different vesions of flutter, one being 1.22.6 stable and the other being 2.2.3 stable. Now I experience on the earlier version, and havn't confirmed whether up to date version has the same issue. I'll keep an eye on it from now on. Unfortunately this is a long time ongoing issue.

@limitless-brain
Copy link

Please note, excluded directories aren't detected by the dart analyzer. For me, I was excluding generated files and some directories, so that Autocomplete wasn’t detecting it. Also, check 'analysis_options.yaml' file for exclude tag.

@tausifali
Copy link

For me, I just change one thing.

Go to Dart Analysis and click on the settings icon and check Scope analysis to the current package. This will solve the problem.

@baljindersinghmaan
Copy link

For me, I just change one thing.

Go to Dart Analysis and click on the settings icon and check Scope analysis to the current package. This will solve the problem.

Worked for me thanks @tausifali

@srawlins srawlins added the type-performance Issue relates to performance or code size label Apr 14, 2022
@dinukakulatunga
Copy link

Scope analysis to the current package

Please can you tell me how to go dart analysis in vs code

@srawlins
Copy link
Member

Apologies for not responding earlier. And sorry but I think I have to ask more clarifying questions.

@kovalyovi in your response 16 months ago, you wrote:

it does not suggest autocompletion for the already imported libraries, for example when I want to set mainAxisAlignment for Column, it would suggest to autocomplete the property mainAxisAlignment but

I had thought that the issue was that after some period of the IDE running with Dart Analysis Server, DAS will stop providing any auto-completion. But from this it sounds like it will still suggest lists of names, but not the ones you expect. Yes? Specifically classes?

And it's the same way with manually imported classes. In fact, it wouldn't even suggest SingleChildScrollView once it stops suggesting but still recognizes it (obviously) once you manually type it in.

Hmm what do you mean by "recognizes" it? Like it highlights the word with the color for classes?

I also wanted to clarify that this issue happens after some period the application is run and/or after I hit Ctrl+F12 (Go to Implementations) on any class and after it waits for 5+ seconds to find all the implementations and I manually hit ESC and do Ctrl+F12 again and it finds it faster. It looks like it first tries to find implementations and takes forever, I 'exit' that search and do it again - it finds those implementations in the respective window but the class autocompletion looks to die somewhere around there.

This is very interesting. It does seem like the request is getting lost or blocked behind the "Go to Implementations" request.


I think @kovalyovi 's issue is specific to this "it works for a while, within one session, then it stops working" problem. If anyone else has an issue of not-yet-imported elements (like classes) not being included anywhere in code completion, ever, please file a separate issue.

@Mamasodikov
Copy link

Mamasodikov commented Jul 2, 2023

For me, I just change one thing.

Go to Dart Analysis and click on the settings icon and check Scope analysis to the current package. This will solve the problem.

Thanks. There is also the same StackOverflow answer which has a checked mark:

https://stackoverflow.com/a/71223418/11618025

@MayurGadhiya
Copy link

BELOW WILL WORK FOR SURE
For those who are still facing the issue after trying the above tricks.

This will not make any sense but it works.

Whenever you face this issue,

  • you just UPGRADE your flutter version to the latest and it will fix that issue.
  • If you're already on the latest version, just downgrade to the last local version and again upgrade to the latest version.
  • If you need to be on the old version, then just upgrade to latest version and downgrade again.

As stupid as it sounds it is working like a charm!

@bwilkerson
Copy link
Member

@scheglov Is the behavior above likely a result of clearing the server's caches? If so, is there some information we're missing in the cache keys? If not, can you think of why upgrading and downgrading that way would cause the analysis to resume?

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) type-performance Issue relates to performance or code size
Projects
None yet
Development

No branches or pull requests