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

パッケージ詳細v1.5.6

flutter_link_preview

これはURLの内容をプレビューするためのプラグインです。

30日間ダウンロード
147
いいね数
76
Pub ポイント
40

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

flutter pub add flutter_link_preview

パッケージ概要

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

flutter_link_preview パッケージは、Flutter アプリケーションが URL の豊富なプレビューを表示できるようにし、リンクされたウェブページからタイトル、説明、画像などのメタデータを取得します。ナビゲーションの前に視覚的な文脈を提供することで、ソーシャルメディアやメッセージアプリにおけるユーザー体験を向上させます。このプラグインは URL の HTML コンテンツを分析し、関連情報を抽出し、カスタマイズ可能な UI 要素を使用した動的レンダリングをサポートしています。軽量で、既存のプロジェクトにスムーズに統合できます。

用途

  • ソーシャルメディアアプリの投稿
  • メッセージアプリのURL共有
  • コンテンツ発見機能
  • ブログまたはニュースフィードのプレビュー
  • ユーザー生成コンテンツの検証

主な機能

  • URLメタデータを自動取得
  • 画像、タイトル、説明のプレビューをサポート
  • カスタマイズ可能な UI コンポーネント
  • 軽量で高速なレンダリング
  • 任意の公開Web URLと互換性があります

適している対象

  • 豊富なURLプレビューを必要とするアプリ
  • ソーシャルプラットフォームを構築する開発者
  • ユーザー共有リンク付きのプロジェクト
  • リアルタイムコンテンツ表示が必要です
  • クロスプラットフォームモバイルアプリ

注意事項

  • メタデータの取得にはインターネット接続が必要です
  • 制限付きまたは非パブリックなURLで失敗する可能性があります
  • パフォーマンスはサーバー応答時間に依存します
  • 複雑なレイアウトのカスタマイズが限られている
  • 直接的な埋め込み動画はサポートしていません

元の README

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

flutter_link_preview

This is a URL preview plugin that previews the content of a URL

Language: English | 中文简体

Demo

Special feature

  • Use multi-processing to parse web pages, avoid blocking the main process
  • Support for content caching and expiration mechanisms to return results faster
  • Better fault tolerance, multiple ways to find icons, titles, descriptions, image
  • Better support gbk code, no messy code
  • Optimized for large files with better crawl performance
  • Support for second hop authentication with cookies
  • Support gif, video and other content capture
  • Supports custom builder

Getting Started

FlutterLinkPreview(
    url: "https://github.com",
    titleStyle: TextStyle(
        color: Colors.blue,
        fontWeight: FontWeight.bold,
    ),
)

Result:

Result Image

Custom Rendering

Widget _buildCustomLinkPreview(BuildContext context) {
  return FlutterLinkPreview(
    key: ValueKey("${_controller.value.text}211"),
    url: _controller.value.text,
    builder: (info) {
      if (info == null) return const SizedBox();
      if (info is WebImageInfo) {
        return CachedNetworkImage(
          imageUrl: info.image,
          fit: BoxFit.contain,
        );
      }

      final WebInfo webInfo = info;
      if (!WebAnalyzer.isNotEmpty(webInfo.title)) return const SizedBox();
      return Container(
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(10),
          color: const Color(0xFFF0F1F2),
        ),
        padding: const EdgeInsets.all(10),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Row(
              children: <Widget>[
                CachedNetworkImage(
                  imageUrl: webInfo.icon ?? "",
                  imageBuilder: (context, imageProvider) {
                    return Image(
                      image: imageProvider,
                      fit: BoxFit.contain,
                      width: 30,
                      height: 30,
                      errorBuilder: (context, error, stackTrace) {
                        return const Icon(Icons.link);
                      },
                    );
                  },
                ),
                const SizedBox(width: 8),
                Expanded(
                  child: Text(
                    webInfo.title,
                    overflow: TextOverflow.ellipsis,
                  ),
                ),
              ],
            ),
            if (WebAnalyzer.isNotEmpty(webInfo.description)) ...[
              const SizedBox(height: 8),
              Text(
                webInfo.description,
                maxLines: 5,
                overflow: TextOverflow.ellipsis,
              ),
            ],
            if (WebAnalyzer.isNotEmpty(webInfo.image)) ...[
              const SizedBox(height: 8),
              CachedNetworkImage(
                imageUrl: webInfo.image,
                fit: BoxFit.contain,
              ),
            ]
          ],
        ),
      );
    },
  );
}

Result Image

Sample code

Click here for a detailed example.

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

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