Skip to content

Commit 2c42dd9

Browse files
committed
Hide for old versions and add icons
1 parent 1963502 commit 2c42dd9

File tree

6 files changed

+41
-1
lines changed

6 files changed

+41
-1
lines changed

resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@
333333
<toolWindow id="Flutter Widget Previewer"
334334
anchor="right"
335335
factoryClass="io.flutter.widgetpreviewer.WidgetPreviewerToolWindowFactory"
336-
icon="FlutterIcons.Flutter" />
336+
icon="FlutterIcons.WidgetPreviewer" />
337337
<!-- Having the projectService defined after the toolWindows allows them to all be picked up by the platform -->
338338
<!-- See https://github.com/flutter/flutter-intellij/issues/8029 -->
339339
<projectService serviceImplementation="io.flutter.view.InspectorView" overrides="false"/>
Lines changed: 12 additions & 0 deletions
Loading
Lines changed: 12 additions & 0 deletions
Loading

src/icons/FlutterIcons.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ private static Icon load(String path) {
99
return IconLoader.getIcon(path, FlutterIcons.class);
1010
}
1111

12+
public static final Icon WidgetPreviewer = load("/icons/expui/widgetPreviewer.svg");
1213
public static final Icon DevToolsDeepLinks = load("/icons/expui/deepLinks.svg");
1314
public static final Icon DevTools = load("/icons/expui/devTools.svg");
1415
public static final Icon DevToolsExtensions = load("/icons/expui/extensions.svg");

src/io/flutter/sdk/FlutterSdkVersion.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ public final class FlutterSdkVersion implements Comparable<FlutterSdkVersion> {
6262

6363
@NotNull
6464
public static final FlutterSdkVersion MIN_SUPPORTS_WIDGET_PREVIEWER = new FlutterSdkVersion("3.37.0");
65+
//public static final FlutterSdkVersion MIN_SUPPORTS_WIDGET_PREVIEWER = new FlutterSdkVersion("3.39.0");
6566

6667
@NotNull
6768
public static final String UNKNOWN_VERSION = "unknown version";

src/io/flutter/widgetpreviewer/WidgetPreviewerToolWindowFactory.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import com.intellij.openapi.wm.ToolWindowFactory;
66
import com.intellij.ui.content.Content;
77
import com.intellij.ui.content.ContentFactory;
8+
import io.flutter.sdk.FlutterSdk;
9+
import kotlin.coroutines.Continuation;
810
import org.jetbrains.annotations.NotNull;
911

1012
public class WidgetPreviewerToolWindowFactory implements ToolWindowFactory {
@@ -17,4 +19,16 @@ public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindo
1719
Content content = contentFactory.createContent(widgetPreviewerPanel, "", false);
1820
toolWindow.getContentManager().addContent(content);
1921
}
22+
23+
@Override
24+
public Object isApplicableAsync(@NotNull Project project, @NotNull Continuation<? super Boolean> $completion) {
25+
// If we know for sure the Flutter SDK version is too old, we won't show options to open this tool window.
26+
FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
27+
if (sdk != null && !sdk.getVersion().canUseWidgetPreviewer()) {
28+
return false;
29+
}
30+
31+
// For other cases, let the panel handle SDK version issues (e.g. missing SDK version).
32+
return true;
33+
}
2034
}

0 commit comments

Comments
 (0)