flutter TextDecoration 和 TextDecorationStyle

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/langzxz/article/details/81563972

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

猜你喜欢

转载自blog.csdn.net/langzxz/article/details/81563972
今日推荐