如何在Android Studio或Visual Studio Code中查找未使用的Flutter类

如何在Android Studio或Visual Studio Code中查找未使用的Flutter类

问题描述:

由于客户端对应用程序需求的快速变化,我有近200个dart文件,其中许多未使用.除了诉诸于手动搜索之外,我有什么方法可以找到未使用的类?在Android Studio中,我可以使用检查代码"功能找到未使用的java或kotlin类.但是我找不到用于飞镖/扑打的相同目的的任何工具.

Because rapid change in app requirement from client, I have nearly 200 dart files, and many of them are unused. Is there any way for me to find unused classes except resorting to manually search one by one? In Android Studio, I can find java or kotlin classes which are unused by using "inspect code" feature. But I can't find any tools for the same purpose for dart / flutter.

谢谢您的帮助.

在VS代码中,文件中所有未使用的类都标记为灰色或带下划线,当您将其悬停在它们上时,会出现一个弹出窗口,告诉您该类尚未在当前文件中的任何地方使用.您可以删除所有此类.

In VS code all unused classes in a file are marked grey or underlined, and when you hover on them a popup will appear telling you that the class has not been used anywhere within your the current file. you can then delete all of such classes.

或者,对于您怀疑未使用的每个班级,您都可以进行全局搜索,方法是按vs左上角的循环图标,然后输入班级名称作为您的搜索键,从那里您可以看到是否使用

alternatively, for each class you suspect is unused, you can make a global search, by pressing on the loop icon on the top left side of vs and input the name of the class as your search key, from there you can see if it is used or not