dart - 如何在 Flutter 中测试/调试摇树?
问题描述
Flutter 自带 tree-shaking 编译。仅包括使用的代码。
但这很容易在不经意间破坏。
有什么方法可以测试和调试摇树?
解决方案
For debugging, it is possible to connect to the Observatory in profile mode. Then inspect the content of desired dart file
You won't see the actual sources in profile mode; but you'll see an overview of what is inside the file, including the defined classes and their methods.
For example, a widget such a the following:
class Home extends StatelessWidget {
_unused() {
print('home');
}
@override
Widget build(BuildContext context) {
return Container();
}
}
when inspected in the Observatory in profile mode; _unused
method will not be in the function list:
推荐阅读
- html - 如何调整表单的输入/输出增量
- php - 给出 HTTP 500 错误,Windows Laravel 5.7
- python - 相同的对象给出不同的值,取决于另一个对象是否被注释掉
- typescript - 如何验证 TypeScript 中的参数数量
- powershell - 将变量传递给函数
- reactjs - 如何从打字稿文件中导出 React 组件
- powershell - Powershell 在 VS Code 终端中的行为与普通终端不同
- php - PHP Benchmarking - 内置 min() 函数似乎很慢
- javascript - 使用 Regex 和 Javascript 从字符串中获取基本 url
- github - 使用 API 获取 Github Enterprise Stats