Flutter. Check if a file exists before loading it
Looks like you want to try to load an ImageProvider
from a folder where the image may or may not exist and then, if it does not, load a fallback asset image (which you can be sure will exist as you'll put it in your root bundle).
Try this:
ImageProvider getImageProvider(File f) { return f.existsSync() ? FileImage(f) : const AssetImage('images/fallback.png');}