Search packages, repositories and app categories

simple_url_preview cover
Package detailsv3.0.1

simple_url_preview

Flutter package to show url preview. Custamizable height, background and text styles, as well as lines.

30-day downloads
103
Likes
77
Pub points
60

Install package

flutter pub add simple_url_preview

Package Overview

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

A Flutter package that displays URL previews with customizable height, background, text styles, and line separators. It enables developers to easily integrate rich media previews into their apps, enhancing user experience when sharing links. The package supports dynamic content rendering from URLs and offers a clean, flexible interface for styling. Ideal for social media apps or messaging platforms where link sharing is common.

Use cases

  • Displaying link previews in chat apps
  • Enhancing social media post feeds
  • Improving user engagement with shared links
  • Integrating rich media previews in messaging interfaces

Key features

  • Customizable preview height
  • Configurable background and text styles
  • Adjustable line separators
  • Dynamic URL content rendering
  • Simple integration with minimal setup

Suitable for

  • Social media applications
  • Messaging and chat platforms
  • Content sharing features
  • Apps requiring rich link previews

Considerations

  • Requires internet access to fetch preview data
  • Limited to basic styling options
  • May need additional handling for complex URLs
  • Depends on external metadata availability

Original README

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

simple_url_preview

likes pub points popularity

Flutter package to show url preview

In Action

Getting Started

This shows url preview of a URL. (Now migrated to null-safety).

Currently only supports Open Graph Protocol

Please use latest version of the package.

How to use ?

Add simple_url_preview to pubspec.yaml, and hit command 'flutter pub get'

dependencies:
  ...
  simple_url_preview: ^3.0.1
1) Simple use:
SimpleUrlPreview(
  url: 'https://pub.dev/',
),
2) Override preview height, padding.(Default and minimum possible height is 130):
SimpleUrlPreview(
  url: 'https://pub.dev/',
  previewHeight: 200,
  previewContainerPadding: EdgeInsets.all(10),
),
3) Override background color:

Default bgColor = Theme.of(context).primaryColor

SimpleUrlPreview(
  url: 'https://pub.dev/',
  bgColor: Colors.red,
),
4) Override title, description, and site style:

Default titleStyle = TextStyle( fontWeight: FontWeight.bold, fontSize: 16, color: Theme.of(context).accentColor )

Default descriptionStyle = TextStyle( fontSize: 14, color: Theme.of(context).accentColor )

Default siteNameStyle = TextStyle( fontSize: 14, color: Theme.of(context).accentColor )

SimpleUrlPreview(
  url: 'https://pub.dev/',
  titleStyle: TextStyle(
    fontSize: 16,
    fontWeight: FontWeight.bold,
    color: Colors.red,
  ),
  descriptionStyle: TextStyle(
    fontSize: 14,
    color: Theme.of(context).primaryColor,
  ),
  siteNameStyle: TextStyle(
    fontSize: 14,
    color: Theme.of(context).primaryColor,
  ),
),
5) If you want closable preview (Click on x to close the preview.):
SimpleUrlPreview(
  url: 'https://pub.dev/',
  isClosable: true,
),
6) Override image loader color and title and description lines:

Default and maximum title lines = 2 and description lines = 3.

SimpleUrlPreview(
  url: 'https://pub.dev/',
  titleLines: 1,
  descriptionLines: 2,
  imageLoaderColor: Colors.white,
),
7) Override onTap callback of the URL preview:

By Default, will open URL in default browser.

SimpleUrlPreview(
  url: 'https://pub.dev/',
  onTap: () => print('Hello Flutter URL Preview'),
),
Contribution:

Would :heart: to see any contributions.

Appreciate:

If you liked my work, show some :heart: by :star: repo.

Also you can appreciate by

Buy Me A Coffee PayPal Logo

Categories

Dependencies

Dependency list 6 items

Source repository

Projects using this package

No data available yet.