title: Flutter: avoid exception from Network Image if unavailable
body: <p>I am trying to avoid an <code>exception</code> in case if network image is available or returns 404. I am expecting, it should return the <code>DefaultImagePlaceholder</code> in that case. FOr that I created a common widget (named <code>getNetworkImageV2</code>) which renders an image, is part of the list widget within the widget is rendering iteratively.</p>
  <pre class="lang-dart prettyprint-override"><code>Widget getNetworkImageV2(BuildContext context, String image, {BoxFit fit = BoxFit.cover, double height = 60.0, double width = 80.0}) {
    return FadeInImage(
      placeholder: MemoryImage(kTransparentImage),
      image: NetworkImage(image),
      fit: fit,
      height: height,
      width: width,
      fadeInDuration: Duration(milliseconds: 100),
      placeholderErrorBuilder: (context, ob, stack) =&gt; Container(child: Image.asset(DefaultPlaceholder, fit: fit, height: height, width: width)),
      imageErrorBuilder: (context, ob, stack) =&gt; Container(child: Image.asset(DefaultPlaceholder, fit: fit, height: height, width: width)),
    );
  }
  
  </code></pre>
  <p><strong>Exception:</strong></p>
  <pre class="lang-sh prettyprint-override"><code>======== Exception caught by image resource service ================================================
  The following NetworkImageLoadException was thrown resolving an image codec:
  HTTP request failed, statusCode: 404, https://i.ytimg.com/vi/WdGayNA5NUA/hqdefault.jpg
  
  When the exception was thrown, this was the stack: 
  #0      NetworkImage._loadAsync (package:flutter/src/painting/_network_image_io.dart:99:9)
  &lt;asynchronous suspension&gt;
  #1      NetworkImage.load (package:flutter/src/painting/_network_image_io.dart:50:14)
  #2      ImageProvider.resolveStreamForKey.&lt;anonymous closure&gt; (package:flutter/src/painting/image_provider.dart:504:13)
  #3      ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:355:22)
  ...
  Image provider: NetworkImage(&quot;https://i.ytimg.com/vi/WdGayNA5NUA/hqdefault.jpg&quot;, scale: 1.0)
  Image key: NetworkImage(&quot;https://i.ytimg.com/vi/WdGayNA5NUA/hqdefault.jpg&quot;, scale: 1.0)
  ====================================================================================================
  
  ======== Exception caught by image resource service ================================================
  HTTP request failed, statusCode: 404, https://i.ytimg.com/vi/4sO_n7fn02I/hqdefault.jpg
  ====================================================================================================
  I/flutter ( 5824): VIDEO-API: http://10.0.2.2:3001/api/_w/videos/1559520687419294485/detail
  
  ======== Exception caught by image resource service ================================================
  
  </code></pre>