How to test/debug tree shaking in Flutter?

后端 未结 1 1004
南笙
南笙 2021-02-14 14:00

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 s

1条回答
  •  [愿得一人]
    2021-02-14 14:15

    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:

    0 讨论(0)
提交回复
热议问题