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

插件详情v1.3.0

rich_text_view

一个简单而强大的富文本视图,支持提及、话题标签、电子邮件、URL 和查看更多。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1050
喜欢数
65
Pub 分数
140

安装插件

flutter pub add rich_text_view

插件介绍

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

rich_text_view 是一个 Flutter 包,提供了一种灵活且直观的方式来显示带有交互元素的富文本,例如提及、话题标签、电子邮件、URL 和“查看更多”功能。它通过在单个文本块内启用可点击和样式化的组件来增强文本渲染。该包支持 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台,非常适合需要动态文本内容的跨平台应用程序。通过 pub 命令进行最少的设置,开发者可以轻松地将富文本功能集成到他们的应用中。

适合场景

  • 社交媒体帖子渲染
  • 聊天消息显示
  • 博客或文章预览
  • 用户生成的内容包含链接
  • 互动评论区

主要特点

  • 支持提及和话题标签
  • 处理 URL 和电子邮件
  • 包含“查看更多”切换按钮
  • 可自定义样式
  • 跨平台兼容性
  • 与 Flutter 的轻松集成

适合对象

  • 包含用户生成内容的应用程序
  • 消息或社交网络应用
  • 内容丰富的用户界面
  • 动态文本显示
  • 寻求轻量级富文本解决方案的开发者

使用建议

  • 仅限预定义的链接类型
  • 无内置图像支持
  • 需要手动处理点击事件
  • 不适用于复杂的富文本编辑
  • 性能可能随超长文本而变化

原始 README

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

rich_text_view

A simple yet powerful rich text view that supports mention, hashtag, email, url and view more.

Example

RichTextView
 RichTextView(
           text:
                      '''Who else thinks it's thinks it's just cool😎 to mention 
                      @jane when #JaneMustLive is trending without even trying 
                      to send a *bold* email to janedoe@gmail.com and verify the
                       facts talkmore of visiting www.janedoe.com''',
                  maxLines: 3,
                  truncate: true,
                  viewLessText: 'less',
                  linkStyle: TextStyle(color: Colors.blue),
                  supportedTypes: [
                    EmailParser(
                        onTap: (email) => print('${email.value} clicked')),
                    PhoneParser(
                        onTap: (phone) => print('click phone ${phone.value}')),
                    MentionParser(
                        onTap: (mention) => print('${mention.value} clicked')),
                    UrlParser(onTap: (url) => print('visting ${url.value}?')),
                    BoldParser(),
                    HashTagParser(
                        onTap: (hashtag) =>
                            print('is ${hashtag.value} trending?'))
                  ]
                )
RichTextEditor

RichTextEditor is an input field that supports suggestions when mentioning or using hashtags


        RichTextEditor(
                      decoration: InputDecoration(
                        border: OutlineInputBorder(
                          borderRadius: BorderRadius.circular(16)),
                      ),
                      suggestionController: SuggestionController(
                      mentionSymbol: '/',
                      position: SuggestionPosition.bottom,
                      mentionSuggestions: [
                        Mention(
                            imageURL: 'imageURL',
                            subtitle: 'nelly',
                            title: 'Nelly Gane'),
                        Mention(
                            imageURL: 'imageURL',
                            subtitle: 'gaus',
                            title: 'Gaus Shell')
                      ],
                      onSearchMention: (term) async {
                        return List.generate(
                            20,
                            (index) => Mention(
                                id: index.toString(),
                                imageURL: 'imageURL',
                                subtitle: term.toLowerCase(),
                                title: '$term $index'));
                      },
                      onMentionSelected: (suggestion) {
                        print(suggestion.id);
                      },
                      onSearchTags: (term) async {
                        return [
                          HashTag(
                              hashtag: '#Dart',
                              subtitle: '30 posts',
                              trending: true),
                          HashTag(
                            hashtag: '#Flutter',
                            subtitle: '56 posts',
                          )
                        ];
                      },
                    ))
Todo
  • Add styles to mentions/hashtags in RichTextEditor

所属分类

源码仓库

使用此插件的项目

暂无相关数据。