flutter / flutter-intellij

Flutter Plugin for IntelliJ
https://flutter.dev/using-ide
BSD 3-Clause "New" or "Revised" License
1.98k stars 318 forks source link

Flutter autocomplete suggestions not working #5978

Closed BojanDolic closed 2 years ago

BojanDolic commented 2 years ago

My autocomplete suggestions just stopped working. As an example, none of the widgets show inside suggestions window when I start typing, here is the screenshot when I want to add BoxDecoration:

First image Second image

Steps to Reproduce

I'm not exactly sure how this happened, but the issue started when I ran android emulator inside tool window ( I ran it as a separate window before.)

I created this project few days ago and everything was working fine until now.

Version info

Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.1, on Microsoft Windows [Version 10.0.19043.1526], locale sr-Latn-BA)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    X cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    X Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
    X Visual Studio not installed; this is necessary for Windows development.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2020.3)
[√] Android Studio (version 2021.1)
[√] IntelliJ IDEA Community Edition (version 2021.1)
[√] Connected device (4 available)
[√] HTTP Host Availability

! Doctor found issues in 2 categories.

Edit: I tried to fix it with invalidate caches and restart, flutter clean, without emulator running, running emulator outside tool window again. None of those things fixed the problem.

stevemessick commented 2 years ago

BoxDecoration is part of Material Design. Do you have uses-material-design: true in your pubspec.yaml?

BojanDolic commented 2 years ago

BoxDecoration is part of Material Design. Do you have uses-material-design: true in your pubspec.yaml?

Yes I do. Everything was working correctly until now. Autocomplete for widgets worked fine until now. I tried restarting my PC also which didn't help.

I also tried autocomplete in another project and it worked fine. I created empty project and autocomplete also worked so it seems that the issue is tied to this project but what is bothering me is that everything was ok until I launched emulator.

stevemessick commented 2 years ago

I would not expect the emulator to affect completion. To be honest, this is a puzzle. I don't know what project-specific thing could cause this. Your quickest remedy may be to re-create your project. If you don't want to do that you could try Flutter Pub Get and Flutter Pub Upgrade from the Tools > Flutter menu.

Have you ever opened the Android module as its own project in Android Studio (Tools > Flutter > Open Android module in Android Studio)? That could possibly cause changes (rarely).

BojanDolic commented 2 years ago

I would not expect the emulator to affect completion. To be honest, this is a puzzle. I don't know what project-specific thing could cause this. Your quickest remedy may be to re-create your project. If you don't want to do that you could try Flutter Pub Get and Flutter Pub Upgrade from the Tools > Flutter menu.

Luckily project is not big so I recreated it. I tried Flutter Pub Get and Flutter Pub Upgrade with no success.

Have you ever opened the Android module as its own project in Android Studio (Tools > Flutter > Open Android module in Android Studio)? That could possibly cause changes (rarely).

I did not. When I go to Tools > Flutter there is no Open Android module in Android option shown.

stevemessick commented 2 years ago

Sorry, but the menu item name changes depending on what is selected in the Project view. In your screen shot, it is named Open for Editing in Android Studio. Have you used that?

Does completion work as expected in the new project?

Since I'm guessing the answers to these two questions are "no" and "yes", I'm going to see if I can get some help trying to understand what went wrong in the original project. @alexander-doroshko @bwilkerson can you think of anything that might explain the original problem?

bwilkerson commented 2 years ago

I can think of a couple of possibilities, but they all seem very unlikely.

Code completion depends on analysis, and analysis depends on having a valid and up-to-date package_config.json file. If something caused the file to be corrupted that could explain the problem.

Analysis also depends on being able to read the source for those packages from the .pub-cache directory. If one of the packages in that directory was corrupted that could potentially cause problems.

Or if some of the files needed for analysis are on a file system that became inaccessible, that could potentially cause problems.

... I ran android emulator inside tool window ( I ran it as a separate window before.)

@stevemessick Is there something different about how the emulator runs when running in a tool window that would explain this?

@BojanDolic If you manually type BoxDecoration does the analyzer find the class (not produce a diagnostic saying that it's undefined)? Can you navigate to it? If the answer to these is "yes" than analysis appears to be working correctly, so my previous guesses are disproven.

BojanDolic commented 2 years ago

@bwilkerson Yes, I can even click to open its source code. Here is the video, hope it will help:

https://user-images.githubusercontent.com/63774884/155766366-a1ae5f19-c4ff-4ebc-91cb-9c81b92f01d0.mp4

stevemessick commented 2 years ago

@BojanDolic When using the project you re-created and running the emulator in the embedded window, does completion work as expected?

BojanDolic commented 2 years ago

@BojanDolic When using the project you re-created and running the emulator in the embedded window, does completion work as expected?

@stevemessick I'm running the emulator as a separate window, I have a fear to run it inside the tool window again because the project grew and I don't want to lose it. Completion works fine in the new project so far.

I tried to recreate the problem in the new project but I couldn't. I tried running the emulator inside the tool window, getting dependencies, but none of that worked.

This is not the first time this happened to me, I was watching a tutorial a couple of weeks ago and I cloned the GitHub repo for the tutorial and after a day or two same thing happened but I was still learning so I thought I messed up something and the project was pretty old in terms of flutter version so I finished that project without completion because it was not big.

stevemessick commented 2 years ago

I'm sorry @BojanDolic but I didn't quite follow that. If you are concerned about possibly corrupting your project then I'd suggest making a zip file of it, then trying the embedded emulator. If completion gets broken you can delete the project and unzip the zip file to restore.

I can't think of any way using the embedded emulator would affect completion. That's why I'm asking if you can confirm that completion does work with the embedded emulator.

Also, what's the tutorial you were using when you had this problem before?

BojanDolic commented 2 years ago

@stevemessick Okay I ran the emulator inside the tool window and it seems that everything works fine, so I'm really confused about what could stop auto-completion to work.

Also, what's the tutorial you were using when you had this problem before?

I was following a course by Angela Yu about flutter, here is the link to the course: Course

stevemessick commented 2 years ago

Thanks for the link. Apparently, something can get mis-configured in the project that causes completion to stop working correctly. Completion is complex; it is actually implemented in the Dart plugin, which uses the Dart analysis server to do the heavy lifting of computing suggestions, but also provides a hook that the Flutter plugin uses to support its outline. So, in theory, something could go wrong in any of the three components (Dart plugin, Flutter plugin, Dart analyzer).

It sounds like you are in good shape now. If this happens again, please let us know. For now, I'm going to keep it open and hope I get some time to investigate the tutorial you referenced.

One more thing. I mentioned flutter pub upgrade earlier, and I see @bwilkerson mentioned a couple symptoms related to that. My hope was that flutter pub upgrade would rebuild the pub cache, but you may need to do flutter clean first. If you still have the broken project, could you try doing Flutter Clean then Flutter Pub Upgrade -- they are both on the Tools > Flutter nested menu. Then let us know if anything changed. I appreciate your help tracking this down.

BojanDolic commented 2 years ago

@stevemessick Thanks for suggestion, I tried Flutter Clean and Flutter Pub Upgrade and nothing changed, completion still does not work.

If I recall correctly when I opened the emulator in a tool window I also added the image as an asset so I had to change pubspec.yaml and run pub get. Maybe that could also point to something. I imported assets before that but I didn't run the emulator inside the tool window so I thought the emulator caused this issue but apparently it didn't. Hope this helps.

stevemessick commented 2 years ago

Thanks for the reply. I can't help thinking something is wrong in your pub cache. But aside from completely deleting it I don't know how to determine if that is true. I don't recommend deleting it because it is shared among all Flutter and Dart projects. I'm out of ideas, I'm afraid. At least we got you back to a workable state.

rorystephenson commented 2 years ago

I think I have the same problem and I've put up with it for quite a while now (between half a year and a year I guess) but it would be great to find a solution.

I blew away the pub cache, ./dart_tool and the flutter/dart plugins in Android Studio with no long. All plugins and Android Studio are up to date.

I'd be up for helping out debugging if there are some log files I can look in to or something else.


To be clear: if I type BoxDecoration there is no completion suggested and I can't auto-import. I can navigate to it though.

rorystephenson commented 2 years ago

@stevemessick I've had a look at the IDE logs whilst opening a project where the flutter importing works fine vs one where it is broken. I noticed that when I open the broken project an NPE is thrown which may be relevant:

logs excerpt ``` 2022-03-17 09:55:57,822 [ 538119] INFO - BridgeProjectLifecycleListener - Using workspace model to open project 2022-03-17 09:55:57,843 [ 538140] INFO - rojectCodeStyleSettingsManager - Initialized from default code style settings. 2022-03-17 09:55:57,845 [ 538142] INFO - pl.projectlevelman.NewMappings - VCS Root: [Git] - [] 2022-03-17 09:55:57,890 [ 538187] INFO - el.ide.impl.WorkspaceModelImpl - Load workspace model from cache in 48 ms 2022-03-17 09:55:57,951 [ 538248] WARN - tartup.impl.StartupManagerImpl - Activities registered via registerPostStartupActivity must be dumb-aware: com.android.tools.idea.stats.AndroidStudioUsageTracker$ProjectLifecycleTracker$projectComponentsInitialized$1@174398e8 2022-03-17 09:55:58,013 [ 538310] INFO - ectsystem.ProjectSystemService - DefaultProjectSystem project system has been detected 2022-03-17 09:55:58,025 [ 538322] INFO - al.NewToolbarRootPaneExtension - ToolbarSettingsService is ExperimentalToolbarSettings 2022-03-17 09:55:58,026 [ 538323] INFO - al.NewToolbarRootPaneExtension - Show new toolbar: false, presentation mode: false 2022-03-17 09:55:58,026 [ 538323] INFO - al.NewToolbarRootPaneExtension - Show old main toolbar: false, old navbar visible: true 2022-03-17 09:55:58,051 [ 538348] INFO - al.NewToolbarRootPaneExtension - ToolbarSettingsService is ExperimentalToolbarSettings 2022-03-17 09:55:58,052 [ 538349] INFO - al.NewToolbarRootPaneExtension - Show new toolbar: false, presentation mode: false 2022-03-17 09:55:58,052 [ 538349] INFO - al.NewToolbarRootPaneExtension - Show old main toolbar: false, old navbar visible: true 2022-03-17 09:55:58,106 [ 538403] INFO - artup.AndroidStudioInitializer - Failed to disable 'org.intellij.plugins.intelliLang.inject.groovy.GrConcatenationInjector' 2022-03-17 09:55:58,463 [ 538760] INFO - ion.DelayedProjectSynchronizer - Workspace model loaded from cache. Syncing real project state into workspace model in 157 ms. Thread[ApplicationImpl pooled thread 74,4,Idea Thread Group] 2022-03-17 09:55:58,465 [ 538762] INFO - ge.ExternalProjectsDataStorage - Load external projects data in 1 millis (read time: 1) 2022-03-17 09:55:58,465 [ 538762] INFO - com.jetbrains.cidr - clangd modules path: /Users/rorystephenson/Library/Caches/Google/AndroidStudio2021.1/caches/clangd_modules/6aedb22a 2022-03-17 09:55:58,465 [ 538762] INFO - ngd.lsp.ClangDaemonContextImpl - Using clangd from: /Applications/Android Studio.app/Contents/plugins/c-clangd/bin/clang/mac/clangd 2022-03-17 09:55:58,467 [ 538764] INFO - pl.projectlevelman.NewMappings - Mapped Roots: 1 2022-03-17 09:55:58,568 [ 538865] INFO - indexing.UnindexedFilesUpdater - Started 2022-03-17 09:55:58,569 [ 538866] INFO - indexing.UnindexedFilesUpdater - Scanning: use 3 scanning threads 2022-03-17 09:55:58,614 [ 538911] INFO - al.NewToolbarRootPaneExtension - ToolbarSettingsService is ExperimentalToolbarSettings 2022-03-17 09:55:58,614 [ 538911] INFO - al.NewToolbarRootPaneExtension - Show new toolbar: false, presentation mode: false 2022-03-17 09:55:58,614 [ 538911] INFO - al.NewToolbarRootPaneExtension - Show old main toolbar: false, old navbar visible: true 2022-03-17 09:55:58,615 [ 538912] WARN - Container.ComponentManagerImpl - Do not use constructor injection (requestorClass=com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvokerImpl) 2022-03-17 09:55:58,631 [ 538928] INFO - ProjectRootPostStartUpActivity - /Users/rorystephenson/code/flutter/falesia/.idea case-sensitivity: expected=false actual=false 2022-03-17 09:55:58,651 [ 538948] INFO - .diagnostic.PerformanceWatcher - Post-startup activities under progress took 345ms; general responsiveness: ok; EDT responsiveness: ok 2022-03-17 09:55:58,829 [ 539126] INFO - indexing.UnindexedFilesUpdater - Scanning completed. Number of scanned files: 48455; Number of files for indexing: 0 took 261ms; general responsiveness: ok; EDT responsiveness: ok 2022-03-17 09:55:58,944 [ 539241] INFO - indexing.UnindexedFilesUpdater - Pushing properties took 114ms; general responsiveness: ok; EDT responsiveness: ok 2022-03-17 09:55:58,956 [ 539253] INFO - indexing.UnindexedFilesUpdater - Finish. No files to index with loading content. 2022-03-17 09:55:59,301 [ 539598] INFO - #com.jetbrains.cidr.lang - Clearing symbols finished in 332 ms 2022-03-17 09:55:59,302 [ 539599] INFO - #com.jetbrains.cidr.lang - Loading Header Maps finished in 0 ms 2022-03-17 09:55:59,302 [ 539599] INFO - #com.jetbrains.cidr.lang - Loading Headers Search Roots finished in 0 ms 2022-03-17 09:55:59,305 [ 539602] INFO - .jetbrains.cidr.lang.modulemap - Loaded 0 module maps in 0 packs for 0 search roots 2022-03-17 09:55:59,305 [ 539602] INFO - #com.jetbrains.cidr.lang - Loading Module Maps finished in 3 ms 2022-03-17 09:55:59,306 [ 539603] INFO - #com.jetbrains.cidr.lang - Loaded 0 tables for 0 files (0 project files) 2022-03-17 09:55:59,306 [ 539603] INFO - #com.jetbrains.cidr.lang - Loading symbols finished in 1 ms 2022-03-17 09:55:59,306 [ 539603] INFO - .jetbrains.cidr.lang.modulemap - Building module maps for 0 (root, configuration) pairs 2022-03-17 09:55:59,311 [ 539608] INFO - #com.jetbrains.cidr.lang - Building module maps... finished in 5 ms 2022-03-17 09:55:59,311 [ 539608] INFO - #com.jetbrains.cidr.lang - Processing module maps... finished in 0 ms 2022-03-17 09:55:59,311 [ 539608] INFO - #com.jetbrains.cidr.lang - Saved 0 module maps in 0 packs 2022-03-17 09:55:59,314 [ 539611] INFO - #com.jetbrains.cidr.lang - Saving Module Maps finished in 3 ms 2022-03-17 09:55:59,317 [ 539614] INFO - #com.jetbrains.cidr.lang - Building symbols for 0 source files 2022-03-17 09:55:59,329 [ 539626] INFO - #com.jetbrains.cidr.lang - Updating symbols finished in 10 ms 2022-03-17 09:55:59,334 [ 539631] INFO - #com.jetbrains.cidr.lang - Building symbols for 0 unused headers 2022-03-17 09:55:59,344 [ 539641] INFO - #com.jetbrains.cidr.lang - Updating symbols finished in 10 ms 2022-03-17 09:55:59,344 [ 539641] INFO - #com.jetbrains.cidr.lang - Updating symbols finished in 10 ms 2022-03-17 09:55:59,344 [ 539641] INFO - #com.jetbrains.cidr.lang - Building symbols in FAST mode, 0 source files from total 0 project files 2022-03-17 09:55:59,345 [ 539642] INFO - #com.jetbrains.cidr.lang - Saving modified symbols for 0 files (0 tables of total 0) 2022-03-17 09:55:59,345 [ 539642] INFO - #com.jetbrains.cidr.lang - Saving symbols finished in 0 ms 2022-03-17 09:55:59,381 [ 539678] INFO - tor.impl.FileEditorManagerImpl - Project opening took 1561 ms 2022-03-17 09:55:59,736 [ 540033] INFO - lutter.run.daemon.DeviceDaemon - starting Flutter device daemon #5: /Users/rorystephenson/sdk/flutter/bin/flutter daemon 2022-03-17 09:56:00,104 [ 540401] WARN - Container.ComponentManagerImpl - Do not use constructor injection (requestorClass=io.flutter.editor.ActiveEditorsOutlineService) 2022-03-17 09:56:01,481 [ 541778] INFO - lutter.run.daemon.DeviceDaemon - flutter device daemon #5: Starting device daemon... 2022-03-17 09:56:01,983 [ 542280] ERROR - til.concurrency.QueueProcessor - null java.lang.NullPointerException at com.intellij.build.progress.BuildProgressImpl.getBuildId(BuildProgressImpl.java:31) at com.intellij.build.progress.BuildRootProgressImpl.getId(BuildRootProgressImpl.java:26) at com.intellij.build.progress.BuildProgressImpl.message(BuildProgressImpl.java:120) at com.intellij.build.progress.BuildRootProgressImpl.message(BuildRootProgressImpl.java:14) at com.intellij.compiler.progress.BuildOutputService.addMessage(BuildOutputService.java:176) at com.intellij.compiler.progress.CompilerTask.addMessage(CompilerTask.java:247) at com.intellij.compiler.impl.CompileContextImpl.addToProblemsView(CompileContextImpl.java:120) at com.intellij.compiler.impl.CompileContextImpl.addMessage(CompileContextImpl.java:105) at com.intellij.openapi.compiler.CompileContext.addMessage(CompileContext.java:63) at com.intellij.openapi.compiler.CompileContext.addMessage(CompileContext.java:46) at org.jetbrains.android.compiler.AndroidAutogenerator$1.compute(AndroidAutogenerator.java:133) at org.jetbrains.android.compiler.AndroidAutogenerator$1.compute(AndroidAutogenerator.java:117) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:840) at org.jetbrains.android.compiler.AndroidAutogenerator.runBuildConfigGenerator(AndroidAutogenerator.java:116) at org.jetbrains.android.compiler.AndroidAutogenerator.run(AndroidAutogenerator.java:94) at org.jetbrains.android.CreateAlarmForAutoGenerationAndroidStartupActivity.doGenerate(CreateAlarmForAutoGenerationAndroidStartupActivity.java:143) at org.jetbrains.android.CreateAlarmForAutoGenerationAndroidStartupActivity.generate(CreateAlarmForAutoGenerationAndroidStartupActivity.java:119) at org.jetbrains.android.CreateAlarmForAutoGenerationAndroidStartupActivity.access$000(CreateAlarmForAutoGenerationAndroidStartupActivity.java:48) at org.jetbrains.android.CreateAlarmForAutoGenerationAndroidStartupActivity$1.run(CreateAlarmForAutoGenerationAndroidStartupActivity.java:69) at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238) at com.intellij.util.Alarm$Request.runSafely(Alarm.java:369) at com.intellij.util.Alarm$Request.run(Alarm.java:355) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:220) at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:216) at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:27) at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:195) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:213) at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:184) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:668) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:665) at java.base/java.security.AccessController.doPrivileged(Native Method) at java.base/java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:665) at java.base/java.lang.Thread.run(Thread.java:829) 2022-03-17 09:56:01,984 [ 542281] ERROR - til.concurrency.QueueProcessor - Android Studio Bumblebee | 2021.1.1 Patch 2 Build #AI-211.7628.21.2111.8193401 2022-03-17 09:56:01,984 [ 542281] ERROR - til.concurrency.QueueProcessor - JDK: 11.0.11; VM: OpenJDK 64-Bit Server VM; Vendor: JetBrains s.r.o. 2022-03-17 09:56:01,984 [ 542281] ERROR - til.concurrency.QueueProcessor - OS: Mac OS X ```
flutter doctor -v ``` [✓] Flutter (Channel stable, 2.10.3, on macOS 11.5.2 20G95 darwin-x64, locale en-GB) • Flutter version 2.10.3 at /Users/rorystephenson/sdk/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7e9793dee1 (2 weeks ago), 2022-03-02 11:23:12 -0600 • Engine revision bd539267b4 • Dart version 2.16.1 • DevTools version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/rorystephenson/sdk/android/ • Platform android-31, build-tools 30.0.2 • ANDROID_HOME = /Users/rorystephenson/sdk/android • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2021.1) • 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.11+0-b60-7590822) [✓] VS Code (version 1.65.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.34.0 [✓] Connected device (1 available) • Chrome (web) • chrome • web-javascript • Google Chrome 99.0.4844.74 [✓] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```
rorystephenson commented 2 years ago

As a last resort I tried using git bisect to determine if it was a non-config related change and it was. For some reason quite a while ago I removed flutter as an explicit dependency in my pubspec.yaml 🤦 . Surprisingly everything continued to work except for auto-completions and running flutter tests via right-click.

Adding the following back has made everything work again, hopefully this solves it for someone else too:

dependencies:
  flutter:
    sdk: flutter
BojanDolic commented 2 years ago

As a last resort I tried using git bisect to determine if it was a non-config related change and it was. For some reason quite a while ago I removed flutter as an explicit dependency in my pubspec.yaml 🤦 . Surprisingly everything continued to work except for auto-completions and running flutter tests via right-click.

Adding the following back has made everything work again, hopefully this solves it for someone else too:

dependencies:
  flutter:
    sdk: flutter

@rorystephenson Thanks for participating and presenting your solution.

Unfortunately, my pubspec.yaml file has those lines and autocomplete doesn't work. Probably something different happened with my project :(

stevemessick commented 2 years ago

@BojanDolic Re-reading this just now, I thought of one more thing to try, and another question.

First, the question. You mentioned doing pub get at one point. Did you do flutter pub get (which the IDE automatically does if you use the menu)? II don't recall why flutter pub get is different from pub get (which is now dart pub get), but apparently it is.

And then you could try deleting the .dart_tool directory and doing flutter pub get to see if that helps.

BojanDolic commented 2 years ago

Sorry for the late response.

I was using pub get from the pubspec.yaml file when I imported library.

I deleted .dart_tool directory and ran flutter pub get and unfortunately, completion still doesn't work.

stevemessick commented 2 years ago

Ah, that would have done flutter pub get so it was doing the right thing. Thanks for the update. I'm out of ideas so I'll leave this open for now.

drowtram commented 2 years ago

我也遇到了这样的问题,最近在学习Flutter开发,在创建工程时,Model Name命名了一个大写开头的英文单词,然后自动补全在我学习的这几天就一直是这样,无法自动补全,今天无意间把Model Name文件名改成了小写开头的英文单词,然后在再Android Studio里面打开工程,自动补全就好使了。

stevemessick commented 2 years ago

According to Google translate, the previous comment is:

I also encountered such a problem. I was learning Flutter development recently. When creating a project, the Model Name named a capitalized English word, and then auto-completion has been like this for the past few days that I have been studying, and it cannot be auto-completed. , today I accidentally changed the Model Name file name to English words starting with lowercase, and then opened the project in Android Studio, and auto-completion was fine.

That's interesting. I'm not sure what Model Name refers to, but based on the capitalization comment I tried changing the name of main.dart to Main.dart and changed the project name in pubspec.yaml to use camel-case. Neither had an effect on completion, though.

@BojanDolic Could your project be affected by capitalization?

BojanDolic commented 2 years ago

@stevemessick I opened the project to test capitalization. Before I did anything I wanted to test if autocompletion works by some miracle so I went to my screen file and to my surprise, autocompletion now WORKS. I didn't change anything nor did I open the project from the last time.

Before I opened this old project I worked on my current project and updated Kotlin and Dart plugins. I restarted AS and then opened my old project. Is it possible that this somehow fixed it ?

stevemessick commented 2 years ago

I'm glad it is working, but I don't know what changed to make it work. However, I'm pretty sure that the problem was not in the Flutter plugin, so I'm closing this issue. Thanks for your help!

ercantomac commented 2 years ago

It recently started to happen to me as well, and I think it was after updating to Flutter 3.0. I hope they fix it with a minor update soon.

developer-farhan commented 2 years ago

It recently started to happen to me as well, and I think it was after updating to Flutter 3.0. I hope they fix it with a minor update soon.

same issue

thassio-vinicius commented 2 years ago

This just started happening to me after Flutter 3.0, suggestions like setState and overrides such as initState and didChangeDependecies aren't working anymore. May we reopen this please?

developer-farhan commented 2 years ago

I second @thassio-vinicius this is a small issue but it lags the productivity of developer and it needs to be fixed

cocoa-rum commented 2 years ago

This just started happening to me after Flutter 3.0, suggestions like setState and overrides such as initState and didChangeDependecies aren't working anymore. May we reopen this please?

Same here. Tried to reset IDE, did not help.


also when I try to auto-import widgets, before it ask me from what I want “material” or “cupertino”. But now autosuggest shows me only one option.


Next ex, I try to type Edg , and there everything but EdgeInsets, and event I typed full word, it lacks of suggestions like EdgeInsets fromLTRB/all etc
This happens a while ago

Android Studio Chipmunk | 2021.2.1 Build #AI-212.5712.43.2112.8512546, built on April 28, 2022 Non-Bundled Plugins: Dart (212.5744), org.jetbrains.kotlin (212-1.6.21-release-334-AS5457.46), io.flutter (68.1.2)

For ex VS Code works as before

Fltme commented 2 years ago

This just started happening to me after Flutter 3.0, suggestions like setState and overrides such as initState and didChangeDependecies aren't working anymore. May we reopen this please?

Omg, finally I find out someone who has the same issue with a setState. I'm new to programming (and learning Flutter) and can't realize the reason for such thing. So, this is just a glitch of 3.0 and will be fixed? ;)

igoriuz commented 2 years ago

This just started happening to me after Flutter 3.0, suggestions like setState and overrides such as initState and didChangeDependecies aren't working anymore. May we reopen this please?

Omg, finally I find out someone who has the same issue with a setState. I'm new to programming (and learning Flutter) and can't realize the reason for such thing. So, this is just a glitch of 3.0 and will be fixed? ;)

Should be fixed according to 3.0.2

EDIT: Apparently setState still not working https://github.com/dart-lang/sdk/issues/49027#issuecomment-1152743664

thassio-vinicius commented 2 years ago

This just started happening to me after Flutter 3.0, suggestions like setState and overrides such as initState and didChangeDependecies aren't working anymore. May we reopen this please?

Omg, finally I find out someone who has the same issue with a setState. I'm new to programming (and learning Flutter) and can't realize the reason for such thing. So, this is just a glitch of 3.0 and will be fixed? ;)

Should be fixed according to 3.0.2

EDIT: Apparently setState still not working dart-lang/sdk#49027 (comment)

Yep, setState still not working, can confirm it.

ranierjardim commented 2 years ago

https://user-images.githubusercontent.com/12734534/174441369-fc4b4bee-eb9e-472d-9572-fc76500707a1.mov

I'm having problems related to imports too, the auto-complete only works when i force using CTRL + SPACEBAR two times

I'm using Flutter latest version (3.0.2)

ahmeedev commented 2 years ago

As a last resort I tried using git bisect to determine if it was a non-config related change and it was. For some reason quite a while ago I removed flutter as an explicit dependency in my pubspec.yaml 🤦 . Surprisingly everything continued to work except for auto-completions and running flutter tests via right-click. Adding the following back has made everything work again, hopefully this solves it for someone else too:

dependencies:
  flutter:
    sdk: flutter

@rorystephenson Thanks for participating and presenting your solution.

Unfortunately, my pubspec.yaml file has those lines and autocomplete doesn't work. Probably something different happened with my project :(

Oh Thanku Man ♥❤💞

ghost commented 2 years ago

Is there a solution? Same problem. Import, setState, etc

ghost commented 2 years ago

Flutter 3.0.3 • channel stable • https://github.com/flutter/flutter.git Framework • revision 676cefaaff (9 days ago) • 2022-06-22 11:34:49 -0700 Engine • revision ffe7b86a1e Tools • Dart 2.17.5 • DevTools 2.12.2

AlexeyRottCr commented 2 years ago

I often encounter this problem...

callmejm commented 2 years ago

I facing this issue after I upgrade my vscode

AbelTarazona commented 1 year ago

Same problem... Android Studio Electric Eel | 2022.1.1 and Flutter 3.7.0

Suggestions not working but autocomplete works using CTRL + SPACEBAR two times

geronimol commented 9 months ago

Same problem: Android Studio Hedgehog | 2023.1.1 Patch 2 Flutter 3.19

EDIT: After days of pain, I was finally able to fix: https://stackoverflow.com/a/63096892/17075671