flutter-intellij: The IDE code completion is more slow on flutter SDK 2.5

My IDE is Idea

I have tried many times.

When i switch to flutter SDK 2.5,the code completion tip will take more time to come out… But when I switch to flutter SDK 2.2.3,it come out very quickly…

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.5.0, on macOS 11.5.2 20G95 darwin-x64, locale
    zh-Hans-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for
      more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2.1)
[✓] Connected device (3 available)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 36
  • Comments: 33 (20 by maintainers)

Commits related to this issue

Most upvoted comments

The problem still exists at least on IntelliJ platform. I’ve raised another issue regarding this.

https://github.com/flutter/flutter-intellij/issues/5825

Re-assigning to Konstantin who is putting together a PR.

I have been looking into this issue and believe that I have a proposal to fix it. Working with @jacob314 to figure out a path forward to staff the work and get the SDK patched.

Yes, assigned to myself. I will chat with Brian and figure out what has changed in the completion algorithm to fix this.

This is now available in Flutter stable, version 2.5.2.

Note, that this is not what users could get right now, but just what could be achieved. All completions above were for already resolved file, just typing Ctrl+Space. In most cases however the user types a character, and so two things happen:

  1. All the library elements are discarded and reloaded from summaries, this prevents returning cached CompletionSuggestions in SuggestionBuilder - we have new instances of all elements, so the Expando is empty for them. See ImportedReferenceContributor: 194.
  2. We spend time to resolve the unit where completion happens. See getResolvedUnit: 112 below. I think the number is high because we spend time to build namespaces of large imported libraries.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

void f() {^
  print(42);
}

As a result, even with filtering performance is not great. 1632430192285 [Perf: <request>: 337, getResolvedUnit: 112, computeSuggestions: 197, DartCompletionManager: 197, build DartCompletionRequest: 0, ArgListContributor: 0, CombinatorContributor: 0, ExtensionMemberContributor: 0, FieldFormalContributor: 0, ImportedReferenceContributor: 194, KeywordContributor: 0, LabelContributor: 0, LibraryMemberContributor: 0, LibraryPrefixContributor: 0, LocalLibraryContributor: 0, LocalReferenceContributor: 0, NamedConstructorContributor: 0, OverrideContributor: 0, RedirectingContributor: 0, StaticMemberContributor: 0, TypeMemberContributor: 0, UriContributor: 0, VariableNameContributor: 0, filter: 1 (count: 3246, matchCount: 146), send notification: 26, ]

It would have been even worse (on about 200 ms), as what we have today.

Fortunately it could be improved so that completion in the trivial code like above is about 20 ms. We need to improve the analyzer to keep these package:flutter libraries. But it will take a few days to carefully implement it.

@SametSahin10 the change is in the SDK. Upgrading Flutter to v2.5.2 (by running flutter upgrade) and restarting your IDE should be enough.

@scheglov it’s my understanding that this is fixed in the main/dev channel (as we reverted in https://github.com/dart-lang/sdk/commit/6207d1da351fcbe385d09625bf4cbe31ff16aaa0), and is being fixed in stable (via cherry-pick https://github.com/dart-lang/sdk/issues/47285), so can this issue be closed?

@jwren Could you look into this? @jacob314 and I were just chatting and realized this is unlikely to be a Flutter plugin issue.

Encountered the same issue(seems OK on vs code), is there any solution for it?

Thanks @maheshmnj . A +1 from me here. I was using Flutter 2.2.1 which was a little bit slow but 2.5 is making intellisense and code completion unusable (its easier to type in the results). I do have a large project but it was kind of ok previously.