Flutter 自定义富文本组件

好用的flutter富文本库。
富文本是很多App都需要的,而且Flutter也提供了富文本功能,但是对于做多语言的APP来说,RichText并不好用,或者说不能用,
今天就给大家推荐一个第三方库 rich_text_widget

使用起来简单又方便,不用分割字符串
具体使用方法参考如下

RichTextWidget(
      // default Text
      Text(
        'You have pushed the button this many times:',
        style: TextStyle(color: Colors.black),
      ),
      // rich text list
      richTexts: [
        BaseRichText(
          "pushed",
          style: TextStyle(color: Colors.yellow),
          onTap: () => {print("touch pushed")},
        ),
        BaseRichText(
          "button",
          style: TextStyle(color: Colors.red),
          onTap: () => {print("touch button")},
        ),
      ],
    )

展示效果如下


1350306-2b5cdcf7b2864f8f.png

参数说明

RichTextWidget:

Name type
defaultText Text
richTexts List <BaseRichText>
caseSensitive bool (defalut = true)

BaseRichText:

Name type
data String
style TextStyle
onTap Function
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容