To preface, I have reviewed the post here, but am still having trouble.
I am building a container that is decorated with an image, only if that image exists in the assets/images/ folder. If it does not exist, the container is decorated with a default image instead.
The image path is formatted string using a variable, image_id, that assumes a String response from an API.
Here is a code / pseudo-code hybrid of what I'm trying to do...
Container(
height: 200,
width: 300,
decoration: BoxDecoration(
image: DecorationImage(
image: (AssetImage('assets/images/${image_id}.jpg') exists) //pseudo-code here
? AssetImage('assets/images/${image_id}.jpg')
: AssetImage('assets/images/default.jpg'),
fit: BoxFit.cover,
),
),
);