Flutter:VSCode中是否存在Widget Inspector对应的when子句?
问题:自定义Flutter组件检查快捷键的when子句配置
我想用shift+cmd+i快捷键切换Widget Inspector的检查功能——在DevTools的Widget Inspector页面处于组件检查状态时,按下该快捷键执行取消检查操作。我尝试在键盘绑定中用when子句检测这个状态,示例配置如下:
{ "key": "shift+cmd+i", "command": "flutter.inspectWidget" }, { "key": "shift+cmd+i", "command": "flutter.cancelInspectWidget" "when": "INSPECTING_A_WIDGET" // 此处应填写什么? }
请问是否存在对应的when子句?或者有没有办法找到所有Flutter相关的when子句?
解决方案
对应的when子句为dart-code:flutter.isInspectingWidget。配置后,该快捷键可实现组件检查状态的切换:未处于检查状态时触发检查,处于检查状态时触发取消检查。最终的键盘绑定配置如下:
{ "key": "shift+cmd+i", "command": "flutter.inspectWidget" }, { "key": "shift+cmd+i", "command": "flutter.cancelInspectWidget", "when": "dart-code:flutter.isInspectingWidget" }
查找Flutter相关when子句的方法
可以通过DevTools控制台查看当前启用的上下文状态,以此确认对应的when子句标识,进而找到所有Flutter相关的状态判断条件。
内容的提问来源于stack exchange,提问作者Michael Gundlach
相关产品推荐
相关产品推荐

