'Autocomplete not working correctly in Android Studio with Flutter - First suggestions are irrelevant

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.



Solution 1:[1]

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

Solution 2:[2]

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

Solution 3:[3]

In my case, I run in android studio terminal:

 flutter upgrade

Solution 4:[4]

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

Solution 5:[5]

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

Solution 6:[6]

In my case, restart android-studio worked.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2
Solution 3 Mina Farid
Solution 4 Hashmitha S
Solution 5 Shyleez
Solution 6 genericUser