flutter显示图标_Flutter小部件之图片(Image)和图标(Icon)

本文介绍了在Flutter中如何使用Image控件显示图片,包括从网络、本地、资源和内存加载图片,并详细讲解了Image的各个属性,如width、height、color、colorBlendMode、fit和alignment等。此外,还探讨了Icon的使用,展示了如何创建和定制字体图标。
摘要由CSDN通过智能技术生成

1. 文章目录

图片(Image)

在Flutter中,我们可以使用Image控件来显示图片,一般来讲我们的图片资源都来源于网络或者本地图片。

Flutter中的Image也是类似。

我们先来看看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,

})

下面我们来看看其常用的属性

属性

值类型

说明

image

ImageProvider

必填参数,接收ImageProvider 类型

semanticLabel

String

图片的描述

excludeFromSemantics

bool

是否从语义上排除该图片,默认值为false

width

double

图片的宽度

height

double

图片的高度

color

Color

图片的前景色,一般不设置或设置透明色,会覆盖掉图片,一般会和colorBlendMode结合使用

colorBlendMode

BlendMode

一般和color结合使用,设置color的混合模式

fit

BoxFit

设置图片的显示模式

alignment

AlignmentGeometry

用于设置图片的对齐方式,默认值:Alignment.center

repeat

ImageRepeat

图片的重复方式,当图片没有完全覆盖掉容器时使用。默认值:ImageRepeat.noRepeat

可以看到,其常用属性跟前端中的c

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值