美文网首页
Flutter Text 文字上下不居中

Flutter Text 文字上下不居中

作者: 北纬357 | 来源:发表于2021-12-23 19:03 被阅读0次
    Flutter Text文本有时候出现不居中的情况,添加StrutStyle属性
    关键代码
                    strutStyle: StrutStyle(
                        fontSize: 11,
                        leading: 0,
                        height: 1.1,
                        // 1.1更居中
                        forceStrutHeight: true, // 关键属性 强制改为文字高度
                      ),
    
    
              Container(
                padding: EdgeInsets.only(right: 16),
                child: Container(
                  padding: EdgeInsets.fromLTRB(4, 4, 4,  4),
                  color: Color(0xFFE6EDFF),
                  child: Text(
                    '负责人',
                    strutStyle: StrutStyle(
                        fontSize: 11,
                        leading: 0,
                        height: 1.1,
                        // 1.1更居中
                        forceStrutHeight: true, // 关键属性 强制改为文字高度
                      ),
                    style: TextStyle(fontSize: 11, color: Color(0xFF2F85F9)),
                    overflow: TextOverflow.ellipsis,
                    textAlign: TextAlign.center,
                  ),
                ),
              )
    

    相关文章

      网友评论

          本文标题:Flutter Text 文字上下不居中

          本文链接:https://www.haomeiwen.com/subject/deqkqrtx.html