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

flutter_linkify のカバー
パッケージ詳細v6.0.0

flutter_linkify

Flutter用にテキスト内のURLとメールアドレスをクリック可能なインラインリンクに変換します。

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

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

flutter pub add flutter_linkify

パッケージ概要

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

flutter_linkify は、プレーンテキスト内の URL および電子メールアドレスを自動的に検出し、クリック可能なリンクに変換する Flutter パッケージです。手動フォーマットを必要とせずにインラインハイパーリンクを有効にするため、テキストレンダリングを向上させます。このパッケージは Android、iOS、Web、macOS、Windows、Linux など複数のプラットフォームをサポートしており、クロスプラットフォームアプリに最適です。Flutter の Text ウィジェットとシームレスに統合され、カスタマイズ可能なリンクスタイルと動作を提供します。

用途

  • URLを含む生テキストをインタラクティブなリンクに変換する
  • メールを mailto: リンクとして表示
  • チャットまたはコメントセクションにおけるユーザー体験の向上
  • 自動リンクを使用してリッチテキストコンテンツを作成する
  • クリック可能な参照を使用してドキュメントやヘルプ画面を構築する

主な機能

  • URL およびメールアドレスの自動検出
  • 複数プラットフォームのサポート
  • カスタマイズ可能なリンクスタイル
  • Flutter の Text ウィジェットとの統合
  • カスタマイズ可能なリンク動作とコールバック
  • http および https プロトコルの両方を処理します

適している対象

  • クリック可能なリンクを含む豊富なテキストが必要なアプリ
  • チャットまたはメッセージインターフェース
  • ドキュメンテーションまたはナレッジベースアプリ
  • ユーザー生成テキストを含むコンテンツ重視のアプリケーション
  • 簡単なハイパーリンク統合を求める開発者

注意事項

  • 一貫した外観を実現するために追加のスタイリングが必要になる場合があります
  • 大規模なテキストブロックによるパフォーマンスへの潜在的影響
  • URLおよびメールパターンに限定(カスタム正規表現は不可)
  • リンクタップイベントの取り扱いに注意が必要です
  • リンク以外の複雑なリッチテキスト形式設定には適していません

元の README

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

flutter_linkify pub package

Turns text URLs and emails into clickable inline links in text for Flutter.

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

Pub - API Docs - GitHub

Install

Install by adding this package to your pubspec.yaml:

dependencies:
  flutter_linkify: ^6.0.0

It is highly recommend that you also add a dependency on url_launcher to open links in the browser/OS.

Usage

Basic:

import 'package:flutter_linkify/flutter_linkify.dart';

Linkify(
  onOpen: (link) => print("Clicked ${link.url}!"),
  text: "Made by https://cretezy.com",
);
Styling

Add a style to non-links (yellow) or links (red), and open in browser using url_launcher:

import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:url_launcher/url_launcher.dart';

Linkify(
  onOpen: (link) async {
    if (!await launchUrl(Uri.parse(link.url))) {
      throw Exception('Could not launch ${link.url}');
    }
  },
  text: "Made by https://cretezy.com",
  style: TextStyle(color: Colors.yellow),
  linkStyle: TextStyle(color: Colors.red),
);

All RichText options are available for use.

Linkify Options

By default, humanization (removal of http:// or https:// from the start of the URL) is enabled. You may disable it by passing options:

Linkify(
  text: "Made by https://cretezy.com",
  options: LinkifyOptions(humanize: false),
);
Selectable Text

Use the SelectableLinkify widget to create selectable text. All SelectableText options are available for use.

SelectableLinkify(
  text: "Made by https://cretezy.com\n\nMail: example@gmail.com",
);
Advance

In the onOpen callback, a LinkableElement is passed in. You can check if it is a UrlElement or EmailElement using is for custom handling.

You can enable parsing of only some link types using the linkifiers option. URL and email are enabled by default.

Full example can be found at example/lib/main.dart.

Example Screenshot

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

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