【Flutter】一、文本及字体样式

一、Text

用于显示文本。

Text(
	'Hello world',
	style: ...
);

1.1 Text构造方法

const Text(
    this.data, {
   
   
    Key key,
    this.style,
    this.strutStyle,
    this.textAlign,
    this.textDirection,
    this.locale,
    this.softWrap,
    this.overflow,
    this.textScaleFactor,
    this.maxLines,
    this.semanticsLabel,
    this.textWidthBasis,
  }) : assert(
         data != null,
         'A non-null String must be provided to a Text widget.',
       ),
       textSpan = null,
       super(key: key);

1.2属性说明

1.2.1 String data

要显示的文本信息

1.2.2 TextStyle style

设置文本样式(颜色、字体大小等)
TextStyle属性说明:

属性 说明
bool inherit 是否继承父节点样式,默认为true
Color color 设置字体颜色
例:Colors.green
Color backgroundColor 设置背景颜色
double fontSize 设置字体大小
FontWeight fontWeight 设置字体粗细
FontWeight.normal:默认,与w400一致
FontWeight.bold:加粗,与w700一致
FontWeight.w[100-900]
FontStyle fontStyle 设置字体样式:
FontStyle.normal:正常
FontStyle.italic:斜体
double letterSpacing 字母间间距
double wordSpacing 单词间间距
TextBaseline textBaseline 对齐文本的水平线
TextBaseline.alphabetic
TextBaseline.ideographic
double height 文本行高
Locale locale 根据地区以不同方式呈现
Paint foreground 文本颜色,使用该属性时,color需为null
Paint()..color = Colors.red
Paint background 文本背景色,使用该属性时,backgroundColor需为null
TextDecoration decoration TextDecoration.none: 默认
TextDecoration.lineThrough: 删除线
TextDecoration.underline: 下划线
TextDecoration.overline: 上划线
Color decorationColor 控制decoration中产生线的颜色
TextDecorationStyle decorationStyle 控制decoration中产生线的样式
TextDecorationStyle.solid: 实线
TextDecorationStyle.double: 双线
TextDecorationStyle.dotted: 点线
TextDecorationStyle.dashed: 虚线
TextDecorationStyle.wavy: 波浪线
double decorationThickness 控制decoration产生线的粗细
String fontFamily 设置文字字体
List<Shadow> shadows 设置字体阴影
Shadow(color: Colors.black, offset: Offset(1.0, 1.0), blurRadius; 5.0)

1.2.3 StrutStyle strutStyle

/// {@macro flutter.painting.textPainter.strutStyle} 
  final StrutStyle strutStyle;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MAXLZ

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值