Flutter--Text封装


import 'package:flutter/material.dart';

class UIText extends StatelessWidget {

  final String text;

  final TextOverflow overflow;
  final TextAlign textAlign;
  final int maxLines;

  final double fontSize;
  final Color color;
  final FontWeight fontWeight;
  final List<Shadow> shadows;
  final TextDecoration decoration;
  final Color decorationColor;
  final TextDecorationStyle decorationStyle;
  final double decorationThickness;

  UIText(this.text, {
    this.overflow,
    this.textAlign,
    this.maxLines,
    this.fontSize,
    this.color,
    this.fontWeight,
    this.shadows,
    this.decoration,
    this.decorationColor,
    this.decorationStyle,
    this.decorationThickness
  });

  @override
  Widget build(BuildContext context) {
    return Text(
      text,
      maxLines: maxLines,
      overflow: overflow,
      textAlign: textAlign,
      style: TextStyle(
        color: color,
        fontSize: fontSize,
        fontWeight: fontWeight,  //文字宽度
        //letterSpacing: -5, //字母之间的间距,可以为负
        //wordSpacing: 10,  //单词之间的间距, 其实是增加文本中空格所占宽度
        //height: 10,  //Text高度为文本实际高度的几倍
        //leadingDistribution: TextLeadingDistribution.even, //针对高度属性的调整,文字在垂直方向的位置
        //textBaseline: TextBaseline.ideographic
        shadows: shadows,
        decoration: decoration,
        decorationColor: decorationColor,
        decorationStyle: decorationStyle,
        decorationThickness: decorationThickness
      ),
    );
  }

}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值