Display a few words in different colors in Flutter

前端 未结 3 1871
感情败类
感情败类 2021-01-04 04:41

I am writing an application which shows a few words in different colors in flutter.

I tried to load HTML files using the plugin flutter_html_view but that one doesn

3条回答
  •  青春惊慌失措
    2021-01-04 04:58

    Use RichText class

    var text = new RichText(
      text: new TextSpan(
        // Note: Styles for TextSpans must be explicitly defined.
        // Child text spans will inherit styles from parent
        style: new TextStyle(
          fontSize: 14.0,
          color: Colors.black,
        ),
        children: [
          new TextSpan(text: 'Hello'),
          new TextSpan(text: 'World', style: new TextStyle(fontWeight: FontWeight.bold)),
        ],
      ),
     );
    

提交回复
热议问题