[英]How to use Flutter's Widget Inspector in Visual Studio Code?
How do you use the Flutter Widget Inspector introduced in VSCode and now enabled ?如何使用 Flutter 在 VSCode 中引入并现已启用的 Widget Inspector? When I debug the app from the IDE or Terminal, nothing happens when I click on any widget in the iOS simulator.
当我从 IDE 或终端调试应用程序时,当我单击 iOS 模拟器中的任何小部件时,没有任何反应。 I could not find any info on VSCode from Google .
我无法从Google找到有关 VSCode 的任何信息。
I am on MacOS Sierra.我在 MacOS Sierra 上。
As of v2.24, the Dart extension for VS Code has integration with the Dart DevTools. 从v2.24开始,VS Code的Dart扩展与Dart DevTools集成。 This has much better inspector functionality than the original Inspect Widget command mentioned by stt106's.
这比stt106提到的原始Inspect Widget命令有更好的检查功能。
With a debugging session active, open the command palette and find the DevTools command. 在调试会话处于活动状态时,打开命令选项板并找到DevTools命令。
The first time you run this you'll may be prompted to activate or upgrade. 第一次运行时,系统可能会提示您激活或升级。
DevTools will then launch in your browser and connect to your debug session. 然后DevTools将在您的浏览器中启动并连接到您的调试会话。
There's more info on the functionality of Dart's DevTools in the DevTools docs . 在DevTools文档中有关于Dart DevTools功能的更多信息。
When debugging, run command Flutter: Inspect Widget , then click on the UI/Widget, it will auto lead you to the code which generates the widget. 调试时,运行命令Flutter:Inspect Widget ,然后单击UI / Widget,它将自动引导您生成窗口小部件的代码。 It only works in debugging mode and the command is not available until the app is loaded in debug.
它仅在调试模式下有效,并且在调试中加载应用程序之前该命令不可用。
Updated method:更新方法:
As of Dart Code (VS code extension) version 2.24.0, The 'Flutter: Inspect Widget' command was replaced with DevTools.从 Dart 代码(VS 代码扩展)版本 2.24.0 开始,“Flutter:Inspect Widget”命令已替换为 DevTools。 (at the time of writing this, the latest version is 3.36.0. To get to the Inspect Widget from the command pallet with >Flutter: Open DevTools or >Dart: Open DevTools, requires several steps.
(在撰写本文时,最新版本是 3.36.0。要从命令面板使用 >Flutter: Open DevTools 或 >Dart: Open DevTools 访问 Inspect Widget,需要几个步骤。
Here's a quicker way:这是一个更快的方法:
Click the debug (bug) button from the side menu and Select Run and Debug or press f5
The Widget inspector will open automatically.小部件检查器将自动打开。
Screenshot of emulator using the Flutter Widget inspector使用 Flutter 小部件检查器的模拟器屏幕截图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.