首页 > 解决方案 > 如果 TextSpan 包含不同的语言,则 TextSpan 的背景具有不同的高度

问题描述

如果存在不同的语言(如中文和英文),则 SelectableText.rich 或 RichText 中 textspan 的背景高度不同。

return Scaffold(
        backgroundColor: Colors.black,
        body: Center(
            child: RichText(
          text: TextSpan(
            text: 'english中文',
            style: TextStyle(
                color: Colors.red,
                backgroundColor: Colors.white,
                fontSize: 18.0),
          ),
        )));

在此处输入图像描述

以下解决方案不起作用,因为 TextSpan 没有属性 strutStyle。
https://medium.com/@najeira/control-text-height-using-strutstyle-4b9b5151668b

请帮助解决这个问题。谢谢。

标签: flutterflutter-layout

解决方案


推荐阅读