在Flutter中以不同的颜色显示几个单词

编程入门 行业动态 更新时间:2024-10-22 23:49:05
本文介绍了在Flutter中以不同的颜色显示几个单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在编写一个应用程序,该应用程序以颤抖的方式显示几个不同颜色的单词.

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

我尝试使用插件flutter_html_view加载HTML文件,但该插件不支持样式(内联).我也尝试使用markdown.

I tried to load HTML files using the plugin flutter_html_view but that one doesn't support styles(inline). I also tried to use markdown.

我该如何实现?

推荐答案

使用 RichText 类

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: <TextSpan>[ new TextSpan(text: 'Hello'), new TextSpan(text: 'World', style: new TextStyle(fontWeight: FontWeight.bold)), ], ), );

更多推荐

在Flutter中以不同的颜色显示几个单词

本文发布于:2023-07-18 04:38:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1141092.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:几个   中以   单词   颜色   Flutter

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!