FLUTTER ECOSYSTEM

Iamstanlee/linkfy_text

一個輕量級的 Flutter 套件,用於將包含 URL、電子郵件和標籤的文本轉換為可點擊連結

linkfy_text 專案封面
Stars
33
Forks
36
最近推送(UTC)
2024年5月29日
專案狀態
未封存
Stanley Akpama GitHub avatar
GITHUB User

Stanley Akpama ↗

Software Engineer

語言DartC++CMakeRubySwiftHTMLCKotlinObjective-C

技術主題

此儲存庫發佈的套件

使用的依賴

依賴清單 5 項
  • platform^3.1.0
  • flutter{"sdk":"flutter"}
  • flutter_test開發依賴{"sdk":"flutter"}
  • test開發依賴^1.16.5
  • lint開發依賴^1.5.3

原始 README

以下為英文專案原文快照,最新內容請造訪 GitHub。

展開 / 收合專案 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

https://raw.githubusercontent.com/Iamstanlee/linkfy_text/main/screenshots/s1.png https://raw.githubusercontent.com/Iamstanlee/linkfy_text/main/screenshots/s2.png

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