搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案