如何在Flutter中测试/调试摇树? [英] How to test/debug tree shaking in Flutter?

查看:92
本文介绍了如何在Flutter中测试/调试摇树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Flutter附带了摇树编译。

Flutter comes with tree shaking compilation. Including only the code used.

但是这很容易在无意中被破坏。

But this is easily breakable inadvertently.

有什么方法可以测试和调试摇树吗?

Is there any way to test and debug tree shaking?

推荐答案

要进行调试,可以以配置文件模式连接到天文台。然后检查所需dart文件的内容

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.

例如,以下小部件:

class Home extends StatelessWidget {
  _unused() {
    print('home');
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

在天文台以配置文件模式进行检查时; _unused 方法将不在函数列表中:

when inspected in the Observatory in profile mode; _unused method will not be in the function list:

这篇关于如何在Flutter中测试/调试摇树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆