FadeInImage.assetNetwork constructor

FadeInImage.assetNetwork({Key key, @required String placeholder, @required String image, AssetBundle bundle, double placeholderScale, double imageScale: 1.0, bool excludeFromSemantics: false, String imageSemanticLabel, String placeholderSemanticLabel, Duration fadeOutDuration: const Duration(milliseconds: 300), Curve fadeOutCurve: Curves.easeOut, Duration fadeInDuration: const Duration(milliseconds: 700), Curve fadeInCurve: Curves.easeIn, double width, double height, BoxFit fit, AlignmentGeometry alignment: Alignment.center, ImageRepeat repeat: ImageRepeat.noRepeat, bool matchTextDirection: false })

Creates a widget that uses a placeholder image stored in an asset bundle while loading the final image from the network.

placeholder is the key of the image in the asset bundle.

image is the URL of the final image.

placeholderScale and imageScale are passed to their respective ImageProviders (see also ImageInfo.scale).

If placeholderScale is omitted or is null, the pixel-density-aware asset resolution will be attempted for the placeholder image. Otherwise, the exact asset specified will be used.

The placeholder, image, imageScale, fadeOutDuration, fadeOutCurve, fadeInDuration, fadeInCurve, alignment, repeat, and matchTextDirection arguments must not be null.

See also:

  • new Image.asset, which has more details about loading images from asset bundles.
  • new Image.network, which has more details about loading images from the network.


  Key key,
  @required String placeholder,
  @required String image,
  AssetBundle bundle,
  double placeholderScale,
  double imageScale = 1.0,
  this.excludeFromSemantics = false,
  this.fadeOutDuration = const Duration(milliseconds: 300),
  this.fadeOutCurve = Curves.easeOut,
  this.fadeInDuration = const Duration(milliseconds: 700),
  this.fadeInCurve = Curves.easeIn,
  this.alignment = Alignment.center,
  this.repeat = ImageRepeat.noRepeat,
  this.matchTextDirection = false,
}) : assert(placeholder != null),
     assert(image != null),
     placeholder = placeholderScale != null
       ? ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale)
       : AssetImage(placeholder, bundle: bundle),
     assert(imageScale != null),
     assert(fadeOutDuration != null),
     assert(fadeOutCurve != null),
     assert(fadeInDuration != null),
     assert(fadeInCurve != null),
     assert(alignment != null),
     assert(repeat != null),
     assert(matchTextDirection != null),
     image = NetworkImage(image, scale: imageScale),
     super(key: key);