Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/io/flutter/utils/FlutterModuleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.intellij.execution.RunnerAndConfigurationSettings;
import com.intellij.facet.Facet;
import com.intellij.facet.FacetManager;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorManager;
Expand Down Expand Up @@ -384,7 +385,7 @@ public static void setFlutterModuleAndReload(@NotNull Module module, @NotNull Pr
ProjectManager.getInstance().reloadProject(project);
}

public static void enableDartSDK(@NotNull Module module) {
public static void enableDartSDK(final @NotNull Module module) {
if (FlutterSdk.getFlutterSdk(module.getProject()) != null) {
return;
}
Expand Down Expand Up @@ -418,10 +419,18 @@ public static void enableDartSDK(@NotNull Module module) {
if (dartSdkPath == null) {
return; // Not cached. TODO call flutterSdk.sync() here?
}
OpenApiUtils.safeRunWriteAction(() -> {
DartPlugin.ensureDartSdkConfigured(module.getProject(), dartSdkPath);
DartPlugin.enableDartSdk(module);
});

// Wrap the write action in a thread-safe way
// See https://github.com/flutter/flutter-intellij/issues/8480
final Application application = ApplicationManager.getApplication();
if (application != null) {
application.invokeLater(() -> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! Is this something we should be doing in general for write actions that don't require synchronicity?

application.runWriteAction(() -> {
DartPlugin.ensureDartSdkConfigured(module.getProject(), dartSdkPath);
DartPlugin.enableDartSdk(module);
});
});
}
}
}
}