Image
is a StatefulWidget
and Image.asset
is just a named constructor, you can use it directly on your widget tree.
AssetImage
is an ImageProvider
which is responsible for obtaining the image of the specified path.
If you check the source code of the Image.asset
you will find that it's using AssetImage to get the image.
Image.asset(String name, {
Key key,
AssetBundle bundle,
this.semanticLabel,
this.excludeFromSemantics = false,
double scale,
this.width,
this.height,
this.color,
this.colorBlendMode,
this.fit,
this.alignment = Alignment.center,
this.repeat = ImageRepeat.noRepeat,
this.centerSlice,
this.matchTextDirection = false,
this.gaplessPlayback = false,
String package,
this.filterQuality = FilterQuality.low,
}) : image = scale != null
? ExactAssetImage(name, bundle: bundle, scale: scale, package: package)
: AssetImage(name, bundle: bundle, package: package),
assert(alignment != null),
assert(repeat != null),
assert(matchTextDirection != null),
super(key: key);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…