繁体   English   中英

如何生成 Flutter 文本字段,在提供建议的情况下下划线不正确的单词?

[英]How to produce Flutter Text Field that underline incorrect words with suggestion provided?

一张图抵得上一千个字,让我向您展示我试图实现的目标: 在此处输入图像描述

该解决方案可以使用 Flutter 内置小部件或第三方小部件。

任何人?

您可以使用 Text.rich() 方法(或RichText Widget )来实现您想要的。
以下片段对应于您的屏幕截图。

  return Scaffold(
      body: Center(
        child: Text.rich(
          TextSpan(
            text: 'I lost ',
            style: TextStyle(fontSize: 24),
            children: <TextSpan>[
              TextSpan(
                  text: 'Password.',
                  style: TextStyle(
                    decoration: TextDecoration.underline,
                  )),
              TextSpan(
                  text: ' ',),
              TextSpan(
                  text: 'What do?',
                  style: TextStyle(
                    decoration: TextDecoration.underline,
                  )),
              // can add more TextSpans here...
            ],
          ),
        ),
      ),
    );

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM