Autocomplete not working correctly in Android Studio with Flutter - First suggestions are irrelevant
Asked Answered
C

10

25

I installed Flutter and Android Studio. I ran flutter doctor - Flutter doctor

I have the Dart plugin installed - v191.8593. image

When I press Ctrl + Space at a very obvious place the AutoComplete do not suggest the right suggestions. Example:

View animation here

As you see the first suggestion are not of type ScrollPhysics and are out of context, and after I scroll down, there are ScrollPhysics suggestions, but they are after some scrolling.

Cacophony answered 21/1, 2020 at 20:11 Comment(4)
I believe I've ran into this when there were some parser errors in the file. Try fixing all parser errors including the completion location, wait a moment, and then editing the completion location again.Upali
Have you tried this with VSCode and it gives the same suggestion list?Chubb
@hola, What do you mean by parsing errors?Cacophony
@sudo_kaizen In VSCode this is the same.Cacophony
S
31

This problem can be fixed by one of the following

  1. Invalidate caches and Restart fixed my problem. Goto

File-> Ivalidate caches / Restart -> Invalidate and Restart

  1. Restart Dart Analysis Server. Follow the pic below enter image description here

Note all above solutions works but are not permanent as it appears there is bug in latest dart Analysis server you can follow subscribe to this reported issue for more updates

Stockist answered 22/11, 2020 at 9:59 Comment(2)
I believe this is the right answer to this question, I was experiencing exactly the same issue and this fixed it.Polled
this is the right answer,it should be the accepted answerBlindage
B
14

Restart Dart Analysis Server :-

  1. Navigate to Dart Analysis tab at bottom.
  2. Click Restart Icon (red colored icon on top left corner of Dart Analysis Window)
  3. Wait for dart analysis to finish.

If it does not work, try this :-

  1. Delete .packages and pubspec.lock files present in your project folder
  2. run flutter pub get
Bobsleigh answered 22/2, 2021 at 6:27 Comment(1)
this solution worked for me. tnxKnoxville
M
14

Enable scope Analysis I fix this by enable the Scope Analysis, at Dart Analysis-> Set Icon-> CheckBox.

Metalware answered 12/8, 2022 at 6:54 Comment(1)
This was my problem. Works for me. ThanksUncrowned
S
3

In my case, I run in android studio terminal:

 flutter upgrade
Sarena answered 27/8, 2020 at 1:45 Comment(0)
U
2

Remove Flutter And Dart Plugins and reinstall it will work for suggestion like stateless and stateful widgets if this don't work then remove all the plugins and reinstall will do!

  • I remove all of my plugin which I added my self don't remove plugins which was install by android studio IDE.
Uninterested answered 5/8, 2023 at 8:35 Comment(1)
in my case using AS 2024.1.1 Canary 6, i only need to disable / enable the dart and flutter pluginKellsie
M
0

if you type stful it gives you the autocompletion of stateful widget for you. or you have to go to

> Setting -> Editor -> Live Templates ->(choose)Flutter->(tick the option)stful

This is the image Depicting the Steps

Megilp answered 10/12, 2020 at 18:9 Comment(1)
To help your answer be more clear, try adding so more details to your solution. E.g. where do you type 'stful'?Nimrod
P
0

I had the same problem and solved it by changing the first letter of my project directory's name from capital letter to lowercase letter. Example : "My_project" => "my_project"

The solution was found there : https://github.com/flutter/flutter-intellij/issues/5978

Prieto answered 25/4, 2022 at 11:56 Comment(0)
R
0

First check in Android Studio > Settings > Editor > Live Templates that is it empty or not.

If it's empty then Make sure you have installed latest version of android studio and autosuggestion is on.

For checking if autosuggestion is on or not follow the steps given below; Android Studio > Settings > Editor > General > Code Completion

And finally follow below steps: Go to Android studio > File > Manage IDE Settings > Restore Default Settings

Restore answered 29/9, 2023 at 13:20 Comment(1)
The One and only working solution , thanksDhow
S
0

You need to add path of your project here for Autocomplete to work or disable it, easiest way is to let auto completes the process

Subheading answered 31/5, 2024 at 12:8 Comment(0)
M
-2

In my case, restart android-studio worked.

Marishamariska answered 25/6, 2021 at 15:7 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.