Flutter系列之UI篇:圖片顯示——Image

目錄導航

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 從內存中加載圖片
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章