The recipe to test a widget that uses CachedNetworkImage and generate a clean golden image without any network request.

cached_network_image is a popular package to handle network images in a Flutter application, it provides:

  • Cache on iOS, Android, and recently macOS,
  • Placeholder widget and nice fade-out transition to the image,
  • Progress download indicator for large images,
  • Offline support (cached images can be displayed without an active connection).

Using it on my Flutter projects has greatly improved the user experience. On the first launch, the app displays the placeholders sized as close as possible to the final images to smoothen the transition when the images are loaded. Then, the subsequent launches are blazing-fast, thanks to the cache (no network requests).

#flutter #mobile-apps #developer

Golden Testing using CachedNetworkImage
5.30 GEEK