Skip to content

Commit 8cda6e4

Browse files
authored
Add widget previewer tool window (#8595)
Changes include: - Logic for starting the widget previewer server (slightly done by AI) - A new tool window (mostly done by AI) - Refactoring browsers to generalize showing a URL (previously we are always showing DevTools URLs) <img width="1399" height="896" alt="Screenshot 2025-10-29 at 11 30 44 AM" src="https://github.com/user-attachments/assets/63bc5aca-f0e7-4996-b9e3-c534aecca701" /> Things that may change further: - Specific version of Flutter SDK for gating - Switching between dark mode/light mode Addresses #8587
1 parent ce144cc commit 8cda6e4

23 files changed

+603
-57
lines changed

.idea/codeStyles/Project.xml

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/META-INF/plugin.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,11 @@
329329
<toolWindow id="Flutter Deep Links" anchor="right" icon="FlutterIcons.DevToolsDeepLinks" factoryClass="io.flutter.deeplinks.DeepLinksViewFactory" />
330330
<toolWindow id="Flutter DevTools" anchor="right" icon="FlutterIcons.DevTools" factoryClass="io.flutter.devtools.RemainingDevToolsViewFactory" />
331331
<toolWindow id="Flutter DevTools Extensions" anchor="right" icon="FlutterIcons.DevToolsExtensions" factoryClass="io.flutter.devtools.DevToolsExtensionsViewFactory" />
332-
<!-- Do not uncomment until ready to release the Property Editor. -->
333332
<toolWindow id="Flutter Property Editor" anchor="right" icon="FlutterIcons.PropertyEditor" factoryClass="io.flutter.propertyeditor.PropertyEditorViewFactory" />
334-
333+
<toolWindow id="Flutter Widget Preview"
334+
anchor="right"
335+
factoryClass="io.flutter.widgetpreview.WidgetPreviewToolWindowFactory"
336+
icon="FlutterIcons.WidgetPreview" />
335337
<!-- Having the projectService defined after the toolWindows allows them to all be picked up by the platform -->
336338
<!-- See https://github.com/flutter/flutter-intellij/issues/8029 -->
337339
<projectService serviceImplementation="io.flutter.view.InspectorView" overrides="false"/>
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading
Lines changed: 4 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 WidgetPreview = load("/icons/expui/widgetPreview.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/FlutterBundle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,10 @@ icon.preview.disallow.flutter_vector_icons=Package "flutter_vector_icons" cannot
187187
icon.preview.disallow.material_design_icons_flutter=Package "material_design_icons_flutter" always displays blank icon previews.
188188
icon.preview.disallow.package.title=Unsupported icon package
189189
icon.preview.analysis=Checking icons...
190+
191+
widget.preview.initializing=Initializing Flutter Widget Preview...
192+
widget.preview.starting=Starting Flutter Widget Preview web server...
193+
widget.preview.loading=Loading Flutter Widget Preview at {0}...
194+
widget.preview.error=Error: {0}
195+
widget.preview.sdk.too.old=Flutter SDK version is too old for Flutter Widget Preview. Please update your SDK.
196+
flutter.sdk.not.found=Flutter SDK not found.

src/io/flutter/devtools/AbstractDevToolsViewFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.flutter.sdk.FlutterSdkVersion;
2020
import io.flutter.utils.AsyncUtils;
2121
import io.flutter.utils.OpenApiUtils;
22+
import io.flutter.view.DevToolsUrlProvider;
2223
import io.flutter.view.EmbeddedBrowser;
2324
import io.flutter.view.ViewUtils;
2425
import kotlin.coroutines.Continuation;
@@ -156,7 +157,7 @@ private void loadDevToolsInEmbeddedBrowser(@NotNull Project project,
156157
FlutterUtils.embeddedBrowser(project))
157158
.ifPresent(embeddedBrowser ->
158159
{
159-
embeddedBrowser.openPanel(toolWindow, getToolWindowTitle(), getToolWindowIcon(), devToolsUrl, System.out::println,
160+
embeddedBrowser.openPanel(toolWindow, getToolWindowTitle(), getToolWindowIcon(), new DevToolsUrlProvider(devToolsUrl), System.out::println,
160161
warningMessage);
161162
devToolsLoadedInBrowser = true;
162163
doAfterBrowserOpened(project, embeddedBrowser);

src/io/flutter/devtools/DevToolsUrl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,14 @@ public String getUrlString() {
214214
return "http://" + devToolsHost + ":" + devToolsPort + "/" + (page != null ? page : "") + "?" + String.join("&", params);
215215
}
216216

217-
public void maybeUpdateColor() {
217+
public boolean maybeUpdateColor() {
218218
final String newColor = devToolsUtils.getColorHexCode();
219219
if (Objects.equals(colorHexCode, newColor)) {
220-
return;
220+
return false;
221221
}
222222

223223
colorHexCode = newColor;
224224
isBright = devToolsUtils.getIsBackgroundBright();
225+
return true;
225226
}
226227
}

0 commit comments

Comments
 (0)