My application has an input that receives a link to retrieve an image from the internet, but if the user enters an invalid link, the app breaks.
I’m currently using Image.network()
to make the image request.
How to handle this exception?
child: ClipRRect( borderRadius: BorderRadius.circular(10), child: Image.network(imageController.text, fit: BoxFit.cover,) ),
Error generated:
Error generated
Resolve the error and handle the thrown exception.
2
Answers
You can check this answer and use error builder.
You can also in your case check a variable using terniary operator:
Solution
you have to future function that check the url
and return it in FutureBuilder also You can use onErrorBuilder
If you choose to use FutureBuilder you can handle all the error in your function