flutter_linkify 3.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 98

flutter_linkify pub package

Turns text URLs and emails into clickable inline links in text for Flutter.

Pub - API Docs - GitHub

Install #

Install by adding this package to your pubspec.yaml:

  flutter_linkify: ^3.1.0

It is highly recommend that you also add a dependency on url_launcher to open links in the browser/OS.

Usage #


import 'package:flutter_linkify/flutter_linkify.dart';

  onOpen: (link) => print("Clicked ${link.url}!"),
  text: "Made by https://cretezy.com",

Styling #

Add a style to non-links (yellow) or links (red), and open in browser using url_launcher:

import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:url_launcher/url_launcher.dart';

  onOpen: (link) async {
    if (await canLaunch(link.url)) {
        await launch(link.url);
      } else {
        throw 'Could not launch $link';
  text: "Made by https://cretezy.com",
  style: TextStyle(color: Colors.yellow),
  linkStyle: TextStyle(color: Colors.red),

All RichText options are available for use.

Linkify Options #

By default, humanization (removal of http:// or https:// from the start of the URL) is enabled. You may disable it by passing options:

  text: "Made by https://cretezy.com",
  options: LinkifyOptions(humanize: false),

Selectable Text #

Use the SelectableLinkify widget to create selectable text. All SelectableText options are available for use.

  text: "Made by https://cretezy.com\n\nMail: example@gmail.com",

Advance #

In the onOpen callback, a LinkableElement is passed in. You can check if it is a UrlElement or EmailElement using is for custom handling.

You can enable parsing of only some link types using the linkifiers option. URL and email are enabled by default.

Full example can be found at example/lib/main.dart.

Example Screenshot

[3.1.0] - 2020-01-10

  • Add SelectableLinkify, for selectable linkified text
  • Add all props for RichText

[3.0.0] - 2019-12-27

  • Update to linkify v2.0.0.
  • Change humanize to options for linkify
  • Change linkTypes to linkifiers for linkify

[2.1.0] - 2019-03-23

  • Split to linkify package.
    • This might break if you were using the internal linkify method.
  • Add text alignment (#11).

[2.0.0] - 2019-03-17

  • Add email address linking (thanks PieterAelse! #8).
  • Breaking: Change API to pass a LinkableElement to the onOpen callback:
    • Accessing the URL can be done by using link.url.
    • You can check using is if it is a LinkElement or EmailElement for custom handling.
  • Added linkTypes option to enable/disable parsing URLs/emails.
  • More line break fixes (should be the last! #9).

[1.1.1] - 2019-03-03

  • Fix humanize option on multi-link text (not being passed down).

[1.1.0] - 2019-02-19

  • Add humanize option to remove protocol.

[1.0.4] - 2019-02-19

  • Fix bug with newlines (#1)

[1.0.3] - 2018-11-06

  • Fix another bug with whitespace (#1)

[1.0.2] - 2018-11-05

  • Fix bug with whitespace (#1)

[1.0.1] - 2018-09-15

  • Add more documentation.

[1.0.0+1] - 2018-09-15

  • Update description.

[1.0.0] - 2018-09-15

  • Initial release.


import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'dart:async';

import 'package:url_launcher/url_launcher.dart';

void main() => runApp(new LinkifyExample());

class LinkifyExample extends StatelessWidget {
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'flutter_linkify example',
      home: Scaffold(
        appBar: AppBar(
          title: Text('flutter_linkify example'),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
              child: Linkify(
                onOpen: _onOpen,
                text: "Made by https://cretezy.com\n\nMail: example@gmail.com",
              child: SelectableLinkify(
                onOpen: _onOpen,
                text: "Made by https://cretezy.com\n\nMail: example@gmail.com",

  Future<void> _onOpen(LinkableElement link) async {
    if (await canLaunch(link.url)) {
      await launch(link.url);
    } else {
      throw 'Could not launch $link';

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_linkify: ^3.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_linkify/flutter_linkify.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
flutter 0.0.0
linkify ^2.0.3 2.0.3
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
pedantic ^1.0.0