Flutter系列之UI篇:图片显示——Image

目录导航

  • Image
    • ImageProvider

Image

Image是用来显示图片的widget,类似android中的ImageView。看一下它的构造方法:

  const Image({
    Key key,
    @required this.image,
    this.semanticLabel,
    this.excludeFromSemantics = false,
    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,
    this.filterQuality = FilterQuality.low,
  }) : assert(image != null),
       assert(alignment != null),
       assert(repeat != null),
       assert(filterQuality != null),
       assert(matchTextDirection != null),
       super(key: key);

ImageProvider

  final ImageProvider image;

image属性为ImageProvider类型,负责提供要显示的图片。常见的ImageProvider的有:

  • AssetImage 加载Asset图片
  • NetworkImage 加载网络图片
  • FileImage 从本地文件系统加载图片
  • MemoryImage 从内存中加载图片

你可能感兴趣的:(跨平台,dart,flutter)