【问题标题】:flutter RichText, TextSpan align颤动 RichText,TextSpan 对齐
【发布时间】:2021-10-04 04:03:57
【问题描述】:

这是我的代码

RichText(
          text: TextSpan(children: [
            TextSpan(
                text: 'flutterABC',
                style: TextStyle(
                    fontSize: isDesktop(context) ? 64 : 32,
                    fontWeight: FontWeight.w800)),
            TextSpan(
                text: 'flutterABC',
                style: TextStyle(
                    fontSize: isDesktop(context) ? 64 : 32,
                    fontWeight: FontWeight.w800,
                    color: Colors.indigo))
          ]),
        ),

像这样。我使用 RichText 和 TextSpan。 当我在 chrome 中运行时,我无法控制对齐 如果 'flutterABCflutterABC' 是一行 > 对齐是中心。 但是如果两行 > align 是开始..

我想始终对齐中心 我能怎么做?

【问题讨论】:

    标签: flutter richtext textspan


    【解决方案1】:

    请试试这个

                 RichText(
                    text: TextSpan(
                        children:[
                      TextSpan(
                          text: 'flutterABC\n',
                          style: TextStyle(
                              fontWeight: FontWeight.w800)),
                      TextSpan(
                          text: 'flutterABC',
                          style: TextStyle(
                              fontWeight: FontWeight.w800,
                              color: Colors.indigo))
                    ]),
                  ),
    

    【讨论】:

    • 我想要一行。只是我想在宽度小的时候用两条线..
    猜你喜欢
    • 2020-06-10
    • 1970-01-01
    • 2022-08-17
    • 2021-08-21
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2022-08-14
    相关资源
    最近更新 更多