In my Flutter app, I return asset (product image) name by:
class Product {
// ...
final int id;
// ...
String get assetName => '$id-0.jpg';
}
And later, I use the asset name like:
// ...
image: AssetImage(product.assetName),
// ...
Now, the problem is some of the images are *.jpg
and some are *.png
like:
Is there a way to tell the Flutter image loader to try to load '$id-0.jpg'
and if the file doesn't exist, then try to load '$id-0.png'
? Perhaps I can do that with regular expressions, but I cannot figure out how.