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

linkfy_text 封面
插件详情v1.1.6

linkfy_text

一个轻量级的 Flutter 包,用于将包含 URL、电子邮件和话题标签的文本链接化,效果类似于 Twitter。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2100
喜欢数
194
Pub 分数
140

安装插件

flutter pub add linkfy_text

插件介绍

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

LinkfyText 是一个轻量级的 Flutter 包,可自动检测并转换文本中的 URL、电子邮件和标签为可点击链接,模仿 Twitter 的链接行为。它通过使文本交互直观化,无需手动格式化链接,从而提升用户体验。该包支持 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台,确保在各种设备上功能一致。适用于社交媒体应用、聊天界面或任何需要动态文本链接的应用。

适合场景

  • 社交媒体动态
  • 聊天应用
  • 用户生成内容展示
  • 电子邮件和URL提取
  • 标签导航

主要特点

  • 自动 URL 检测
  • 电子邮件链接化
  • 标签转为可点击的标签
  • 跨平台支持
  • 轻量且快速

适合对象

  • 包含丰富文本内容的应用程序
  • 带有用户输入的交互式 UI
  • 内容密集型界面
  • 实时消息应用
  • 极简设计,支持动态文本

使用建议

  • 可能需要自定义样式以适应复杂主题
  • 仅限基本链接类型(不支持提及或自定义模式)
  • 对超长文本的性能影响
  • 无内置的嵌套链接处理
  • 依赖外部正则表达式模式进行检测

原始 README

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

linkfy_text

Lightweight flutter package that detects linkable patterns(urls, emails, hashtags, etc) in a text and makes them clickable. It also allows you to customize the style of the linkified text and the link itself. It also allows you to choose what type of link to linkify in a text.¬

pub package CI coverage Status

Usage

To use this package, add linkfy_text as a dependency in your pubspec.yaml file.

Example:

// first import the package
import 'package:linkfy_text/linkify_text.dart';

Container(
    child: LinkifyText(
    "This text contains a url: https://flutter.dev",
    linkStyle: TextStyle(color: Colors.blue),
    onTap: (link) {
        /// do stuff with `link`
        },
    );
)

Be default, The above snippet would linkify all urls in the string, you can choose what type of link to linkify by passing the LinkTypes parameter

Container(
    child: LinkifyText(
    "This text contains a url: https://flutter.dev and #flutter",
    linkStyle: TextStyle(color: Colors.blue),
    LinkTypes: [LinkType.url, LinkType.hashtag]
    onTap: (link) {
        /// do stuff with `link` like
        /// if(link.type == Link.url) launchUrl(link.value);
        },
    );
)

API Reference

LinkfyText
Parameter Type Description
textStyle TextStyle style applied to the text
linkStyle TextStyle style applied to the linkified text. defaults to textStyle
LinkTypes List<LinkType> a list of LinkType used to override the links to be linkified in a text either a url, hashtag or email. defaults to [LinkTypes.url]
onTap Function(Link) function called when a link is pressed
LinkType
Parameter Type Description
type Link the link type either url, email or hashtag, @mention
value String value the link holds

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a feature, please send a pull request.

TODO

  • LinkifyTextField widget

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目