Home > database >  Сhecking the photo link
Сhecking the photo link

Time:10-08

I used the api to get the url of the image. There is a chance that I will get a broken link and the image won't load. I want a placeholder instead of a broken link. How should I implement this check?

CodePudding user response:

You can check out this package: https://pub.dev/packages/cached_network_image

dependencies:
  cached_network_image: ^3.2.2

This way, CachedNetworkImage will throw an error in every initial state, as the URL string is always empty or broken. And when the URL is available, the CachedNetworkImage will load the image.

  • Related