搜索插件、代码仓与 APP 分类

utils_rinch_text 封面
插件详情v1.0.3

utils_rinch_text

此方法返回一个适合格式化长文本的 TextSpan 列表。此实现支持以下标签,参见示例。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
19
喜欢数
9
Pub 分数
160

安装插件

flutter pub add utils_rinch_text

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

utils_rinch_text 包提供了一个实用方法,用于使用 TextSpan 格式化长文本,支持自定义标签以实现富文本渲染。它能够以嵌入式格式显示结构化文本,非常适合动态内容(如聊天消息或格式化描述)。该包在所有主要平台上均兼容,并简化了复杂文本布局的创建,无需手动管理 Span。它通过简洁的 API 高效解析和渲染带标签的文本。

适合场景

  • 聊天消息格式化
  • 动态内容渲染
  • UI 组件中的富文本
  • 格式化描述
  • 用户生成文本处理

主要特点

  • 支持自定义文本标签
  • 生成 TextSpan 列表
  • 跨平台兼容性
  • 简单的 API 集成
  • 高效的文本解析

适合对象

  • 需要丰富文本的应用程序
  • 聊天或消息界面
  • 内容密集型UI
  • 文本格式化工具
  • 寻求简洁的 Flutter 开发人员

使用建议

  • 需要正确的标签语法
  • 仅限文本格式化
  • 无内置样式选项
  • 依赖于正确的输入结构
  • 不适合复杂的布局

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

This method returns a list of TextSpan ideal for formatting long text this implementation supports the following tags, see example.

<a>Link web<a>
<p> add paragraph

Captura de tela 2023-02-03 195339

Add custom tags

Text de example:

 String textExample = """
  <i>Flutter<i> is an open source mobile app development framework <l>created by Google.<l> 
  It enables the creation of native apps for <i>iOS and Android<i> with a single Dart code base. 
  With its flexible and performant architecture, <o>Flutter has become one of the most 
  popular options for building mobile apps.<o> In addition, it offers a wide range of widgets 
  and animated visual effects that help you create attractive and intuitive applications. <p>
  For more information about Flutter, head over to the main 
  page at <a>https://flutter.dev/<a> and start <b>exploring the possibilities<b> 
  of this powerful app development tool.
  """;

Implementation

RichText(
   text: TextSpan(
     children: UtilsRinchText.generate(
       textExample,
       customTags: {
         "<i>": const TextStyle(
           fontWeight: FontWeight.bold,
           fontSize: 20,
         ),
         "<l>": const TextStyle(
           fontSize: 20,
           color: Colors.red,
           fontWeight: FontWeight.bold,
         ),
         "<a>": const TextStyle(
           color: Colors.green,
           fontWeight: FontWeight.bold,
         ),
         "<o>": const TextStyle(
           fontWeight: FontWeight.bold,
           color: Colors.blue,
           fontSize: 20,
         ),
         "<b>": const TextStyle(
           fontWeight: FontWeight.bold,
           color: Colors.orange,
           fontSize: 20,
         ),
       },
     ),
   ),
 ), 

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目

暂无相关数据。