flutter TextDecoration 和 TextDecorationStyle

TextDecoration

是用来在文本附近绘制线性装饰的类.

目前有4个属性
lineThrough 在每行文字中画一条线 (删除线)
none 不做任何事情
overline 在每行文本上方画一条线 (上划线)
underline 在每行文本下面画一条线(下划线)

lineThroughlineThrough

nonenone

overlineoverline

underlineunderline

代码

TextStyle _getTextStyle(BuildContext context) {
    return new TextStyle(
      color: Colors.black54,
      decoration: TextDecoration.overline,
    );
  }

new Text('巧克力?' , style: _getTextStyle(context),)

TextDecorationStyle

这枚举style可能控制画实线,虚线,两条线,点, 波浪线

/// The style in which to draw a text decoration
enum TextDecorationStyle {
  ///画一条直线
  solid,

  /// 画两条线
  double,

  /// 画圆点虚线
  dotted,

  /// 画破折号虚线
  dashed,

  /// 画波浪线
  wavy
}

solidsolid
doubledouble
dotteddotted
dasheddashed
wavywavy

只修改函数 _getTextStyle

TextStyle _getTextStyle(BuildContext context) {
    return new TextStyle(
      color: Colors.black54,
      decoration: TextDecoration.overline,
      decorationStyle: TextDecorationStyle.solid
    );
  }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值