A cross-platform flutter package to convert your links into rich beautiful previews.

Overview

Link Preview Generator

Pub build CodeFactor License Donate

A cross-platform flutter package to convert your links into rich beautiful previews.
This package is inspired from Any Link Preview package, but the entire parsing & scrapping logic has been re-written to be more robust & to support more links. It also provides control over complete customization of the widget.

Usage

Widget Example

import 'package:link_preview_generator/link_preview_generator.dart';

/// Generate a beautiful link preview card widget
LinkPreviewGenerator(
    bodyMaxLines: 3,
    link: 'https://github.com/ghpranav/link_preview_generator',
    linkPreviewStyle: LinkPreviewStyle.large,
    showGraphic: true,
)

Function Example

import 'package:link_preview_generator/link_preview_generator.dart';

/// Pass the URL to be parsed/scraped
/// to build your own custom widget with parsed data
final WebInfo info = await LinkPreview.scrapeFromURL('https://github.com/ghpranav/link_preview_generator');

/// Description of the page.
final String description = info.description;

/// Domain name of the link.
final String domain = info.domain;

/// Favicon of the page.
final String icon = info.icon;

/// Image URL, if present any in the link.
final String image = info.image;

/// Title of the page.
final String title = info.title;

/// Link preview type of the rule used for scrapping the link.
/// Returns [LinkPreviewType.error] if the scrapping is failed.
final LinkPreviewType type = info.type;

/// Video URL, if present any in the link.
final String video = info.video;

Props & Methods

LinkPreviewGenerator

PropName Description PropType value required
link URL to display as preview String true
backgroundColor Customize the background colour of widget Color default(Color.fromRGBO(248, 248, 248, 1.0)) false
bodyMaxLines Maximum number of description body lines int default(auto) false
bodyStyle Customize the description body style TextStyle N.A false
bodyTextOverflow Overflow type for description body text TextOverflow default(TextOverflow.ellipsis) false
borderRadius Border radius for the widget card double default(12.0) false
boxShadow Box shadow for the widget card List<BoxShadow> false
cacheDuration Cache the parsed result for a certain duration Duration default(Duration(days: 7)) false
errorBody Body that need to be shown if parsing fails String default(Oops! Unable to parse the url.) false
errorImage Image URL that will be shown if parsing fails String default(A crying semi-soccer ball image) false
errorTitle Title that need to be shown if parsing fails String default(Something went wrong!) false
errorWidget Widget shown if parsing fails. Defaults to plain container Widget false
graphicFit Adjust the box fit of the image BoxFit default(BoxFit.cover) false
linkPreviewStyle Link Preview card display style LinkPreviewStyle default(large) small,large false
onTap Function that needs to be called when user taps on the card Function() default(launchURL(link)) false
placeholderWidget Widget shown when parsing the link Widget false
proxyUrl Proxy URL to pass that resolve CORS issues on web String example(https://cors-anywhere.herokuapp.com/) false
removeElevation To remove the widget card elevation bool default(false) true,false false
showBody Show or Hide body text (Description) bool default(true) true,false false
showDomain Show or Hide domain name bool default(true) true,false false
showGraphic Show or Hide the image after parsing, if available bool default(true) true,false false
showTitle Show or Hide title bool default(true) true,false false
titleStyle Customize the title style TextStyle N.A false

Contributing

  1. Fork it

  2. Create your feature branch (git checkout -b my-new-feature)

  3. Commit your changes (git commit -am 'Added some feature')

  4. Push to the branch (git push origin my-new-feature)

  5. Create new Pull Request

Contributors

Image of contributors

License

MIT

You might also like...

A beautiful cross platform mobile web app use this and ENJOY (2 page) - Flutter UI from scratch

course_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Feb 9, 2022

A JSON serialize class to convert 'to' and 'from' JSON format Enums, DateTime and any of your own classes.

A JSON serialize class to convert 'to' and 'from' JSON format Enums, DateTime and any of your own classes. Introduction Jsonize solves the problem of

Nov 17, 2022

A simple dart package to convert large numbers to a human readable format. 1278 to 1.2K instead, for example.

A simple dart package to convert large numbers to a human readable format. 1278 to 1.2K instead, for example. Features Represents large numbers in ter

Oct 8, 2022

A flutter plugin to get facebook deep links and log app events using the latest Facebook SDK to include support for iOS 14

Facebook Sdk For Flutter LinkedIn GitHub facebook_sdk_flutter allows you to fetch deep links, deferred deep links and log facebook app events. This wa

Dec 17, 2022

Flutter plugin which helps you to find links in String using NSDataDetector and Linkify

Flutter plugin which helps you to find links in String using NSDataDetector and Linkify

Flutter's Native Linkify native_linkify is a Flutter plugin. Use it to find links in plain-text. The plugin uses NSDataDetector for iOS and macOS; Lin

Nov 29, 2022

a small app with a collection to WhatsApp group links

a small app with a collection to WhatsApp group links

linki A community based app for links to social media groups. Intro Linki is a simple app that shows an interactive list of links to social media grou

Sep 19, 2021

A cross-platform Flutter home workout app that respects your privacy. THIS IS A GITLAB MIRROR, file issues and contribute there.

A cross-platform Flutter home workout app that respects your privacy. THIS IS A GITLAB MIRROR, file issues and contribute there.

Feeel Feeel is an open-source workout app for doing simple at-home exercises. This is a rewrite of the original app in Flutter, to make development ea

Dec 26, 2022

Portarius is a free, open-source, cross-platform mobile application that allows you to manage your Portainer sessions.

Portarius is a free, open-source, cross-platform mobile application that allows you to manage your Portainer sessions.

Portarius [Latin: Porta/Door Arius/Keeper] Features User management See running/stopped containers (and also start/stop and restart them) See containe

Jan 7, 2023

A rich, convenient, easy-to-use flutter page transition package

A rich, convenient, easy-to-use flutter page transition package

flutter_page_transition A rich, convenient, easy-to-use flutter page transition package. README in Chinese Some Demos Getting Started Add this to your

Sep 27, 2022
Comments
  • LinkPreviewGenerator not updating inside of a ListView

    LinkPreviewGenerator not updating inside of a ListView

    I have a list view of LinkPreviewGenerators but when I call setState and update the data that the list view is reading from the LinkPreviewGenerators don't refresh. I have confirmed that refreshing works with just Text widgets

    opened by nico671 1
  • Warning: Operand of null-aware operation

    Warning: Operand of null-aware operation

    this work well. but, warnings appear like this.

    : Warning: Operand of null-aware operation '!' has type 'int' which excludes null.
    ..…rulesdefault.scrapper.dart:128
              if (img.naturalWidth! > img.naturalHeight!) {
    
                      ^
    : Warning: Operand of null-aware operation '!' has type 'int' which excludes null.
    ../…/rules/default.scrapper.dart:128
              if (img.naturalWidth! > img.naturalHeight!) {
                                          ^
    : Warning: Operand of null-aware operation '!' has type 'int' which excludes null.
    ../…/rules/default.scrapper.dart:130
                if (img.naturalWidth! / img.naturalHeight! > 3) {
    
                        ^
    : Warning: Operand of null-aware operation '!' has type 'int' which excludes null.
    ../…/rules/default.scrapper.dart:130
    
                if (img.naturalWidth! / img.naturalHeight! > 3) {
                                            ^
    : Warning: Operand of null-aware operation '!' has type 'int' which excludes null.
    ../…/rules/default.scrapper.dart:135
                if (img.naturalHeight! / img.naturalWidth! > 3) {
                        ^
    
    opened by masahiro-kato 0
  • [ImgBot] Optimize images

    [ImgBot] Optimize images

    Beep boop. Your images are optimized!

    Your image file size has been reduced 🎉

    Details

    | File | Before | After | Percent reduction | |:--|:--|:--|:--| | /assets/demo-2.png | 874.34kb | 858.21kb | 1.85% | | /assets/demo-1.png | 859.12kb | 845.18kb | 1.62% | | | | | | | Total : | 1,733.46kb | 1,703.39kb | 1.73% |


    📝 docs | :octocat: repo | 🙋🏾 issues | 🏪 marketplace

    ~Imgbot - Part of Optimole family

    opened by imgbot[bot] 0
Releases(v1.2.0)
Owner
Pranav Bedre
Ex Lead - DSC JSSSTU | Flutter Developer | Computer Science Engineering Student | JSSSTU Mysuru
Pranav Bedre
A free tool to convert any website into a cross platform native application.

SWAB (Spyxpo Web to App Builder) Convert any website into an iOS/Android/Windows/macOS/Linux app. This is a preview build for testing purposes major u

Spyxpo 7 Jan 1, 2023
A feature-rich cross-platform webview using webview_flutter for mobile and iframe for web. JS interop-ready.

A feature-rich cross-platform webview using webview_flutter for mobile and iframe for web. JS interop-ready. Getting started Gallery Basic usage Featu

null 2 Mar 17, 2022
DeerNote is a solution for cross-platform rich editor

#DeerNote is a solution for cross-platform rich editor ###DeerNote contains parts as follows: db: mongodb server: nodejs app: flutter launch mongdb se

null 3 Dec 6, 2022
Easy to use text widget for Flutter apps, which converts inlined urls into working, clickable links

LinkText Easy to use text widget for Flutter apps, which converts inlined URLs into clickable links. Allows custom styling. Usage LinkText widget does

Aleksander Woźniak 20 Nov 4, 2022
Call Kit is a prebuilt feature-rich call component, which enables you to build one-on-one and group voice/video calls into your app with only a few lines of code.

Call Kit (ZegoUIKitPrebuiltCall) Call Kit is a prebuilt feature-rich call component, which enables you to build one-on-one and group voice/video calls

ZEGOCLOUD 9 Dec 26, 2022
Csv to list for web - Convert a CSV into a list in order to populate a firebase database

My goal is to convert a CSV into a list in order to populate a firebase database

null 0 Jan 26, 2022
Simple Dart package for creating mailto links in your Flutter apps or web pages

mailto Simple Dart package for creating mailto links in your Flutter and Dart apps The mailto package helps you build mailto links and provides you wi

SMAHO Engineering OSS 21 Jul 8, 2022
A Flutter widget to dynamically add links to your text.

linkable A Flutter widget to add links to your text. By default, the Text or RichText widgets render the URLs in them as simple text which are not cli

Anup Kumar Panwar 18 Dec 15, 2021
Access links between your devices in real time!

Lineker Description Lineker allows you to manage links between your desktop and smartphone in real time, saving and deleting at any time. Create filte

Blackoutseeker 2 Aug 5, 2022
Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

BetterX.io 4 Oct 2, 2022