-
Notifications
You must be signed in to change notification settings - Fork 258
[New Analyzer] Ability to check for unused assets #816
Comments
So, the problem we got stuck earlier is - if a path to asset is combined with variables and the user has several assets having the same name, but located in different sub-directories, then how to properly notify the user, which one of the assets is not used? For example,
and then in code final path = '...'
final pathToAsset = '$path/settings.png' What if even the |
Okk yes this can be possible. So I think in this case, we will have to use the concept of macros (not exactly macros, but just an example) so if the analyzer finds that the path is containing a variable or a non-constant string, replace that variable with the value of variable. I understand this can be real challenging. |
Maybe there is something wrong with your thinking? How to determine the value of variable or a non-constant string? And what value we should use? The value may be requested from the server. |
I think the analyzer should determine which assets must be used. Then the others may not be used. But we have no way to confirm. Because the factors that affect the variables may be the data from server, or the user's operation. |
Summary
So one of the main reasons for increased app size is assets. While developing, we constantly keep on adding some images or fonts that our client wants and when it changes, we forget to remove the unused assets.
This analyzer (not linter rule) would provide the list of all the assets that we have not used in the project.
Possible Solution
pubspec.yaml
or assets folder (if the developer has simply importedassets/
).What category of rule is this? (place an "X" next to just one item)
[ ] Warns about a potential error (problem)
[ ] Suggests an alternate way of doing something (suggestion)
[x] Other (please specify:)
Are you willing to submit a pull request to implement this rule? I don't have much idea about how to write the script but if guided, definitely!
The text was updated successfully, but these errors were encountered: