I tried to call a picture with a bad url and show an image when failed... but flutter throw an exception and try catch not working during run development.
var url = "http://badUrl.com"
try {
return Image.network(
url,
width: pictureSize.width,
height: pictureSize.height,
fit: BoxFit.fitWidth,
errorBuilder: (BuildContext context, Object exception,
StackTrace stackTrace) {
return Image.asset("assets/img/logo.png");
},
);
} catch (error) {
return Image.asset("assets/img/logo.png");
}
I have already try that but it doesn't working