linkify 4.1.0 icon indicating copy to clipboard operation
linkify: ^4.1.0 copied to clipboard

Low-level link (text, URLs, emails, user tagging) parsing library in Dart.

linkify pub package #

Low-level link (text, URLs, emails) parsing library in Dart.

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

Flutter library.

Pub - API Docs - GitHub

Install #

Install by adding this package to your pubspec.yaml:

  linkify: ^4.0.0

Usage #

import 'package:linkify/linkify.dart';

linkify("Made by");
// Output: [TextElement: 'Made by ', UrlElement: '' (, TextElement: ' ', EmailElement: '' (]

Options #

You can pass LinkifyOptions to the linkify method to change the humanization of URLs (turning to

// [UrlElement: '' (]

linkify("", options: LinkifyOptions(humanize: false));
// [UrlElement: '' (]
  • humanize: Removes http/https from shown URLs
  • removeWww: Removes www. from shown URLs
  • looseUrl: Enables loose URL parsing (should parse most URLs such as
    • defaultToHttps: When used with [looseUrl], default to https instead of http
  • excludeLastPeriod: Excludes . at end of URLs

Linkifiers #

You can pass linkifiers to linkify as such:

linkify("@cretezy", linkifiers: [UserTagLinkifier()]);

Available linkifiers:

  • EmailLinkifier
  • UrlLinkifier
  • UserTagLinkifier

Custom Linkifier #

You can write custom linkifiers for phone numbers or other types of links. Look at the URL linkifier for an example.

This is the flow:

  • Calls parse in the linkifier with a list of LinkifyElement. This starts as [TextElement(text)]
  • Your parsers then splits each element into it's parts. For example, [TextElement("Hello")] would become [TextElement("Hello "), UrlElement("")]
  • Each parsers is ran in order of how they are passed to the main linkify function. By default, this is URL and email linkifiers
pub points


verified publisher

Low-level link (text, URLs, emails, user tagging) parsing library in Dart.



API reference


Icon for licenses.MIT (LICENSE)


Packages that depend on linkify