Flutter Image 参数详解

1.继承关系

Object > Diagnosticablet > DiagnosticableTreet > Widgett > StatefulWidgett > Image

2.介绍

一个显示图片的widget,支持图像格式:JPEG,PNG,GIF,动画GIF,WebP,动画WebP,BMP和WBMP

3.创建Image

一共有五种方法:

Image()        

构造方法

Image.asset        

加载资源图片

Image.file        

加载本地图片

Image.network        

加载网络图片

Image.memory        

加载Uint8List资源图片

4.Image()        

构造方法创建,构造方法: 

  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);

下面参数详解:

4.1 Key key

官方解释:https://flutterchina.club/widgets-intro/#key

4.2 ImageProvider image

sdk已经给了ImageProvider的子类满足开发使用,一般不使用构造方法创建Image,因为其他四个静态方法分别使用到了5个子类,进行显示图片!

 如Image.asset使用了ExactAssetImage或者AssetImage

image = scale != null

         ? ExactAssetImage(name, bundle: bundle, scale: scale, package: package)

         : AssetImage(name, bundle: bundle, package: package)

4.3 String semanticLabel

图像的语义描述,用于向Andoid上的TalkBack和iOS上的VoiceOver提供图像描述

talkback是一款由谷歌官方开发的系统软件,它的定位是帮助盲人或者视力有障碍的用户提供语言辅助

Voiceover功能是APPLE公司在2009年4月新推出的一种语音辅助程序

4.4 bool excludeFromSemantics = false

是否启用图像的语义描述

4.5 double width

控件宽度

4.6 double  height

控件高度

4.7 Color color

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值