【发布时间】:2018-12-22 19:49:50
【问题描述】:
有没有办法在模拟器中检查 Flutter App 元素? 我正在使用 VS 代码而不是 android studio 我想从正在运行的模拟器中检查元素。
【问题讨论】:
-
关注此公开issue
标签: visual-studio-code flutter
有没有办法在模拟器中检查 Flutter App 元素? 我正在使用 VS 代码而不是 android studio 我想从正在运行的模拟器中检查元素。
【问题讨论】:
标签: visual-studio-code flutter
从版本 2.24.0 开始,DevTools 选项是用于调试和检查的新功能。
打开命令面板 Ctrl+Shift+P 并输入:
>Dart: Open DevTools
要访问它,您的调试会话必须正在运行:
【讨论】:
在 Flutter 项目中检查 Widget:
1- 打开命令面板 (Ctrl+Shift+P (Cmd+Shift +P 在 macOS 上))。
2- 选择 Flutter: Inspect Widget 命令并按 Enter。
3- 点击模拟器中的任何小部件。
4- 查看小部件树。
5- 祝你好运。
【讨论】:
在运行您的应用程序时,出现热重载后,在您的终端中按“i”。还有一些其他的功能。要找到它,请在终端中按“h”。
【讨论】:
我使用快捷键:Ctrl+Alt+D(使用Ubuntu + VSCode)。
不要忘记应用程序必须已经在调试模式下运行,就像 Evandro 提到的那样。
【讨论】:
其实,当你在运行flutter run之后在终端输入h,你就会得到所有这些东西;
Flutter run key commands.
r Hot reload. ???
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
s Save a screenshot to flutter.png.
b Toggle the platform brightness setting (dark and light mode). (debugBrightnessOverride)
w Dump widget hierarchy to the console. (debugDumpApp)
t Dump rendering tree to the console. (debugDumpRenderTree)
L Dump layer tree to the console. (debugDumpLayerTree)
S Dump accessibility tree in traversal order. (debugDumpSemantics)
U Dump accessibility tree in inverse hit test order. (debugDumpSemantics)
i Toggle widget inspector. (WidgetsApp.showWidgetInspectorOverride)
I Toggle oversized image inversion ?️. (debugInvertOversizedImages)
p Toggle the display of construction lines. (debugPaintSizeEnabled)
o Simulate different operating systems. (defaultTargetPlatform)
z Toggle elevation checker.
g Run source code generators.
M Write SkSL shaders to a unique file in the project directory.
v Launch DevTools.
P Toggle performance overlay. (WidgetsApp.showPerformanceOverlay)
a Toggle timeline events for all widget build methods. (debugProfileWidgetBuilds)
为了直接在浏览器中打开DevTool,您可以输入v。
结果会是这样的;
【讨论】: