FadeInImage.assetNetwork constructor
- Key? key,
- required String placeholder,
- ImageErrorWidgetBuilder? placeholderErrorBuilder,
- required String image,
- ImageErrorWidgetBuilder? imageErrorBuilder,
- AssetBundle? bundle,
- double? placeholderScale,
- double imageScale = 1.0,
- bool excludeFromSemantics = false,
- String? imageSemanticLabel,
- Duration? fadeOutDuration,
- Curve? fadeOutCurve,
- Duration fadeInDuration = const Duration(milliseconds: 700),
- Curve fadeInCurve = Curves.easeIn,
- double? width,
- double? height,
- BoxFit? fit,
- Color? color,
- BlendMode? colorBlendMode,
- Color? placeholderColor,
- BlendMode? placeholderColorBlendMode,
- BoxFit? placeholderFit,
- FilterQuality filterQuality = FilterQuality.medium,
- FilterQuality? placeholderFilterQuality,
- AlignmentGeometry alignment = Alignment.center,
- ImageRepeat repeat = ImageRepeat.noRepeat,
- bool matchTextDirection = false,
- FadeInImageTransition transition = FadeInImageTransition.sequential,
- int? placeholderCacheWidth,
- int? placeholderCacheHeight,
- int? imageCacheWidth,
- int? imageCacheHeight,
- bool useLogicalCacheSize = false,
Creates a widget that uses a placeholder image stored in an asset bundle while loading the final image from the network.
The placeholder argument is the key of the image in the asset bundle.
The image argument is the URL of the final image.
The placeholderScale and imageScale arguments are passed to their
respective ImageProviders (see also ImageInfo.scale).
If placeholderScale is omitted or is null, pixel-density-aware asset
resolution will be attempted for the placeholder image. Otherwise, the
exact asset specified will be used.
If placeholderCacheWidth, placeholderCacheHeight, imageCacheWidth,
or imageCacheHeight are provided, it indicates to the
engine that the respective image should be decoded at the specified size.
The image will be rendered to the constraints of the layout or width
and height regardless of these parameters. These parameters are primarily
intended to reduce the memory usage of ImageCache.
If useLogicalCacheSize is true, the cache dimensions are interpreted
as logical pixels instead of physical pixels. Set this to true when
the cache dimensions describe the image's on-screen size in logical
pixels. The flag applies to both the placeholder and the image.
The transition argument controls how the widget animates from the
placeholder to the image; see FadeInImageTransition.
See also:
- Image.asset, which has more details about loading images from asset bundles.
- Image.network, which has more details about loading images from the network.
Implementation
FadeInImage.assetNetwork({
super.key,
required String placeholder,
this.placeholderErrorBuilder,
required String image,
this.imageErrorBuilder,
AssetBundle? bundle,
double? placeholderScale,
double imageScale = 1.0,
this.excludeFromSemantics = false,
this.imageSemanticLabel,
Duration? fadeOutDuration,
Curve? fadeOutCurve,
this.fadeInDuration = const Duration(milliseconds: 700),
this.fadeInCurve = Curves.easeIn,
this.width,
this.height,
this.fit,
this.color,
this.colorBlendMode,
this.placeholderColor,
this.placeholderColorBlendMode,
this.placeholderFit,
this.filterQuality = FilterQuality.medium,
this.placeholderFilterQuality,
this.alignment = Alignment.center,
this.repeat = ImageRepeat.noRepeat,
this.matchTextDirection = false,
this.transition = FadeInImageTransition.sequential,
int? placeholderCacheWidth,
int? placeholderCacheHeight,
int? imageCacheWidth,
int? imageCacheHeight,
bool useLogicalCacheSize = false,
}) : assert(
transition != FadeInImageTransition.fadeInOver ||
(fadeOutDuration == null && fadeOutCurve == null),
'fadeOutDuration and fadeOutCurve must be omitted or null when '
'transition is FadeInImageTransition.fadeInOver, since the placeholder '
'is not faded out in that mode.',
),
fadeOutDuration = fadeOutDuration ?? _defaultFadeOutDuration,
fadeOutCurve = fadeOutCurve ?? _defaultFadeOutCurve,
placeholder = placeholderScale != null
? ResizeImage.resizeIfNeeded(
placeholderCacheWidth,
placeholderCacheHeight,
ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale),
useLogicalSize: useLogicalCacheSize,
)
: ResizeImage.resizeIfNeeded(
placeholderCacheWidth,
placeholderCacheHeight,
AssetImage(placeholder, bundle: bundle),
useLogicalSize: useLogicalCacheSize,
),
image = ResizeImage.resizeIfNeeded(
imageCacheWidth,
imageCacheHeight,
NetworkImage(image, scale: imageScale),
useLogicalSize: useLogicalCacheSize,
);