简体   繁体   English

如何在 flutter Text Widget 中将句子中的单词加粗

[英]How to make a word Bold in a sentence in flutter Text Widget

I have a paragraph to be displayed on a page, But in that sentence, some words need to be bold我有一个段落要显示在页面上,但是在那句话中,有些词需要加粗

final aboutSectionPieceOfContent = """
We are a "Not for Profit" trust venture building Wellness on wheels to address the serious problem of open defecation which is a major health risk for all in developing countries.

We are on the mission of integrating technology with our social cause.
​
We are in the process of providing a holistic approach to social responsibility keeping health, sensitization, safety, and Eco-friendly solutions
""";

This will be used as Text(aboutSectionPieceOfContent);这将用作Text(aboutSectionPieceOfContent);

But the problem is I want some words to be Bold for example in first para line 1, Not for Profit must be bold但问题是我希望某些词是粗体的,例如在第一段第 1 行中, Not for Profit必须是粗体

How do I get that Thanks for the help我怎么得到那个谢谢你的帮助

You can use RichText.您可以使用富文本。

RichText(
          text: TextSpan(
            text: "We are a  ",
            style: TextStyle(color: Colors.black),
            children: <TextSpan>[
              TextSpan(
                text: "\"Not for Profit\" ",
                style: TextStyle(
                  // color: Colors.green,
                  fontWeight: FontWeight.bold,
                ),
                //recognizer: _longPressRecognizer,
              ),
              TextSpan(
                  text:
                      "trust venture building Wellness on wheels to address the serious problem of open defecation which is a major health risk for all in developing countries.We are on the mission of integrating technology with our social cause.We are in the process of providing a holistic approach to social responsibility keeping health, sensitization, safety, and Eco-friendly solutions"),
            ],
          ),
        )

You should use Flutter RichText widget您应该使用 Flutter RichText小部件

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

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