'How to cause a compile-time or lint-time error if code is referencing non-exist Flutter assets?
I have some flutter assets, say, file_one.png, file_two.json etc, and I use them in my code using Image.asset, Lottie and so on.
The problem is, how to cause a compile-time or lint-time error if code is referencing non-exist Flutter assets? For example, if I write Image.asset('assets/not_exist_file.png'), I hope I can get an error at compile time instead of at runtime. Since this can be statically checked and a compile-time or lint-time error is much, much better than a bug at runtime.
Thanks for any suggestions!
Solution 1:[1]
I just tried npm -g i sharp on my M1 MacBook Air and it works, so..there are a few things to know about your machine's environment.
The brew formula is actually called
libvips. I didn't have it installed andnpm i sharpworked fine without it.Take a detailed look at https://sharp.pixelplumbing.com/install#custom-libvips and the next section "Building from Source". If you have libvips installed, you may need to set the env var
SHARP_IGNORE_GLOBAL_LIBVIPSto ignore it.Make sure other npm dependencies in
package.jsonare up to date if possible.As a workaround you could create a i386 arch copy of Terminal or iTerm2, place it in your Applications folder called "iTerm2 Rosetta", or something similar, and use the Get Info dialog on the file to enable Rosetta. You could even set a custom icon for it.

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ivan |
