简体   繁体   English

如何在 Visual Studio Code 中使用 Flutter 的 Widget Inspector?

[英]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.

相关问题 Flutter Visual Studio 代码中的检查器 - Flutter Inspector in Visual Studio code 如何使用 Visual Studio Code IntelliSense 显示 Flutter 小部件文档? - How to show Flutter Widget documentation with Visual Studio Code IntelliSense? Flutter 检查员在 Visual Studio Code 中窃听/冻结 - Flutter inspector bugging out/freezing in Visual Studio Code 在 Visual Code Studio 中哪里可以找到 Flutter 布局检查器? - Where can I find Flutter layout inspector in Visual Code Studio? 在 Visual Studio Code 中找不到 Flutter Inspector/Toggle Debug Paint - Can't find Flutter Inspector / Toggle Debug Paint in Visual Studio Code Visual Studio代码-使用检查器协议进行调试 - visual studio code - debugging with inspector protocol 如何使用正则表达式在 Visual Studio Code 的代码片段中“大写和替换”? - How to use Regex to 'capitalize and replace' in Visual Studio Code's snippets? 如何在 Visual Studio Code 的代码片段中使用正则表达式来“大写和替换”? - How to use Regex to 'uppercase and replace' in Visual Studio Code's snippets? 在 flutter 中编码时,如何在 android studio 上使用 Visual Studio 代码功能? - How can I use visual studio code features on android studio while coding in flutter? 当我使用 Dart 和 Flutter 时,Visual Studio 代码无法正常工作 - Visual studio code is not working properly when I use Dart and Flutter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM