Search packages, repositories and app categories

Package detailsv1.5.6

flutter_link_preview

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

30-day downloads
147
Likes
76
Pub points
40

Install package

flutter pub add flutter_link_preview

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The flutter_link_preview package enables Flutter applications to display rich previews of URLs, fetching metadata such as title, description, and image from the linked webpage. It enhances user experience in social media and messaging apps by providing visual context before navigation. The plugin works by analyzing the URL's HTML content and extracting relevant information, supporting dynamic rendering with customizable UI elements. It is lightweight and integrates seamlessly into existing projects.

Use cases

  • Social media app posts
  • Messaging app URL sharing
  • Content discovery features
  • Blog or news feed previews
  • User-generated content validation

Key features

  • Auto-fetches URL metadata
  • Supports image, title, and description preview
  • Customizable UI components
  • Lightweight and fast rendering
  • Works with any public web URL

Suitable for

  • Apps needing rich URL previews
  • Developers building social platforms
  • Projects with user-shared links
  • Real-time content display needs
  • Cross-platform mobile apps

Considerations

  • Requires internet access for metadata fetch
  • May fail on restricted or non-public URLs
  • Performance depends on server response time
  • Limited customization for complex layouts
  • Does not support embedded videos directly

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package