簡體   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