New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature_request] A way to find all unused assets #69
Comments
Hey, @kaciula Thank you for opening this issue. This sounds like a pretty useful thing. However, this is quite complicated. We can't rely on compiler warnings but we will have to run dart analyzer on the whole project and then process the result of it and look for issues in generated files to determine which assets are not being used.
The analyzer shows this if you open the generated files. [If implemented] we can also show this in the terminal when build is complete (or could have separate command as well) but that's it, unless, we delete those files and references (which seems handy but I am not sure). Despite all the complications, this sounds like a fun project and seems almost feasible. However, I don't have bandwidth to do this in near future. If someone is willing to implement then I am more than happy to guide and review it. If I get some time and by then if no one has done it then I may pick it up and do it. Or maybe not. I can't promise anything solid yet. For that, I am keeping this issue open. Thanks. |
@BirjuVachhani Thanks for the response.
I don't see any warnings for unused assets when I open the generated file. Please see the attachment. The playing.png asset is not being used anywhere and I do not see any warning. Am I missing something? Should it show? Also, you don't have to manually run the analyzer. It runs automatically on the whole project. The idea however is that the analyzer does not show unused variable warning for public variables anywhere in the project. It only shows for unused private variables. So I don't know how this limitation can be overcome. |
Ah! You're right! I never noticed it. I looked up this on internet and found these threads: Haven't read all of them comments but seems like it is kind of a big deal that no one has yet solved perfectly(except dart metrics package) |
Can you not just search for |
Of course. But when you have 100 images you do not have the time to go through each and every one. |
@kaciula is right! It may take huge amount of time to evaluate all the assets to see if they are being used or not! Another challenge is, this cannot be done efficiently by just looking into project files programmatically. It could be that |
I wish there was a way to find out if an asset is not being used anywhere in the app. If it's not being used, it makes sense for me to manually delete it and shrink the app's size.
Is this possible to be implemented? I am imagining we should somehow rely on the compiler warning that a particular generated field for an asset is not being used anywhere inside the app. What do you think?
The text was updated successfully, but these errors were encountered: