首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何对齐RichText/TextSpan块?

如何对齐RichText/TextSpan块?
EN

Stack Overflow用户
提问于 2022-11-05 00:38:10
回答 1查看 29关注 0票数 0

我的目标是对齐下面的文本块,使其变得居中。当前对齐在左边。我尝试过使用textAlign.center,但这似乎不适用于RichText/TextSpan。任何帮助都非常感谢!

代码语言:javascript
复制
  RichText(
    text: TextSpan(
      children: <TextSpan>[
        const TextSpan(
            text:
                'Hello ',
      ),
        TextSpan(
            text: 'Click here',
            style: const TextStyle(
                color: Colors.blue, fontSize: 13),
            recognizer: TapGestureRecognizer()
              ..onTap = () {
              
              }),
         const TextSpan(
            text: ' this is a test',
          ),
      ],
     ),
  ),
EN

回答 1

Stack Overflow用户

发布于 2022-11-05 03:16:20

RichTextCenter

代码语言:javascript
复制
  Center(
    child: RichText(
      text: TextSpan(
      children: <TextSpan>[
        const TextSpan(text: 'Hello '),
        TextSpan(
          text: 'Click here',
          style: const TextStyle(color: Colors.blue, fontSize: 13),
          recognizer: TapGestureRecognizer()..onTap = () {},
        ),
        const TextSpan(text: ' this is a test'),
      ],
    ),
  ),
),
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74324243

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档