パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v5.0.0

linkify

Dart における低レベルリンク(テキスト、URL、メールアドレス、電話番号、ユーザータグ)パースライブラリ。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
39万
いいね数
182
Pub ポイント
150

パッケージをインストール

flutter pub add linkify

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Linkify は、テキストを解析し、リンク、URL、電子メールアドレス、電話番号、ユーザータグを検出するために設計された低レベルのDartライブラリです。複数のプラットフォームでプレーンテキストから構造化データを検出し、抽出するための軽量かつ効率的な方法を提供します。チャットインターフェース、ソーシャルメディアフィード、コンテンツレンダリングなど、自動テキスト処理が必要なアプリケーションに最適です。このライブラリはAndroid、iOS、Web、macOS、Windows、Linuxをサポートしており、広範な互換性を確保しています。UIコンポーネントは含まれていませんが、正確なパースに焦点を当てており、カスタムウィジェットやテキストプロセッサへの統合に適しています。

用途

  • ユーザーが生成したコンテンツの解析
  • テキストからURLとメールアドレスを抽出する
  • チャットやメッセージアプリの構築
  • クリック可能なリンクを使用したテキスト表示の向上
  • ソーシャルメディア投稿の処理
  • 連絡先情報の抽出を自動化する

主な機能

  • URL、メールアドレス、電話番号、ユーザーのタグをサポート
  • クロスプラットフォーム互換性
  • 軽量で効率的なパース
  • 組み込みのUIコンポーネントなし
  • パターン検出の高い正確性
  • カスタムリンクタイプ用に拡張可能

適している対象

  • テキスト中心のアプリを開発する開発者
  • 自動リンク検出を必要とするアプリ
  • カスタムテキスト処理パイプライン
  • チャットまたはフォーラムアプリ
  • コンテンツレンダリングシステム

注意事項

  • リンクのビジュアルレンダリングを提供しない
  • タップ処理の手動実装が必要
  • 基本的なテキストパターンに限定
  • 複雑なHTMLパースには適していません
  • 組み込みのスタイルオプションなし
  • 外部の論理に依存して相互作用する

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

linkify pub package

Low-level link (text, URLs, emails, phone numbers, user tags) parsing library in Dart.

Required Dart >=2.12 (has null-safety support).

Flutter library.

Pub - API Docs - GitHub

Install

Install by adding this package to your pubspec.yaml:

dependencies:
  linkify: ^5.0.0

Usage

import 'package:linkify/linkify.dart';

linkify("Made by https://cretezy.com person@example.com");
// Output: [TextElement: 'Made by ', UrlElement: 'https://cretezy.com' (cretezy.com), TextElement: ' ', EmailElement: 'person@example.com' (person@example.com)]
Options

You can pass LinkifyOptions to the linkify method to change the humanization of URLs (turning https://example.com to example.com):

linkify("https://cretezy.com");
// [UrlElement: 'https://cretezy.com' (cretezy.com)]

linkify("https://cretezy.com", options: LinkifyOptions(humanize: false));
// [UrlElement: 'https://cretezy.com' (https://cretezy.com)]
  • humanize: Removes http/https from shown URLs
  • removeWww: Removes www. from shown URLs
  • looseUrl: Enables loose URL parsing (should parse most URLs such as abc.com/xyz)
    • defaultToHttps: When used with [looseUrl], default to https instead of http
  • excludeLastPeriod: Excludes . at end of URLs
Linkifiers

You can pass linkifiers to linkify as such:

linkify("@cretezy", linkifiers: [UserTagLinkifier()]);

Available linkifiers:

  • EmailLinkifier
  • UrlLinkifier
  • PhoneNumberLinkifier
  • UserTagLinkifier

Custom Linkifier

You can write custom linkifiers for phone numbers or other types of links. Look at the URL linkifier for an example.

This is the flow:

  • Calls parse in the linkifier with a list of LinkifyElement. This starts as [TextElement(text)]
  • Your parsers then splits each element into it's parts. For example, [TextElement("Hello https://example.com")] would become [TextElement("Hello "), UrlElement("https://example.com")]
  • Each parsers is ran in order of how they are passed to the main linkify function. By default, this is URL and email linkifiers

カテゴリー

ソースリポジトリ

このパッケージを使用しているプロジェクト