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

Overview

Build & Test codecov License: Apache 2.0

Flutter's Native Linkify

Example screenshot

native_linkify is a Flutter plugin. Use it to find links in plain-text.

The plugin uses NSDataDetector for iOS and macOS; Linkify for Android. This means the plugin finds links in the same way most native apps do, giving much more accurate results than existing pure dart packages.

This plugin doesn't have any widgets to show inline links out of the box, but it has everything you need to create them in a way you like.

Here's example which shows how to implement widget that's turns text URLs, E-Mails and phones into clickable links:

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

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

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  final entries = await NativeLinkify.linkify(
      'text link.com [email protected] and +79990000000');
  // Note that this method is asynchronous because the plugin works with native
  // functions via MethodChannel and MethodChannel works only in asynchronous way
  // in real app it's better to linkify text at the place where you load it from
  // your data source
  runApp(
    MyApp(
      entries: entries,
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key, required this.entries}) : super(key: key);

  final List<LinkifyEntry> entries;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: SafeArea(
          child: Text.rich(
            TextSpan(
              children: [
                for (final l in entries)
                  if (l is LinkifyText)
                    // Regular text, text without links
                    TextSpan(
                      text: l.text,
                    )
                  else if (l is LinkifyUrl)
                    // Link
                    TextSpan(
                      text: l.text,
                      style: const TextStyle(color: Colors.blue),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () => launch(l.url),
                    )
              ],
            ),
          ),
        ),
      ),
    );
  }
}
You might also like...

This is a Flutter plugin that takes a JSON string and converts it onto a customizable Flutter Widget.

This is a Flutter plugin that takes a JSON string and converts it onto a customizable Flutter Widget.

Colored JSON Convert JSON string into customizable widget. Getting Started ColoredJson is a stateless widget that produces a structured view of JSON s

May 20, 2022

Totally *legal* Instagram automation, crosses your user follower/following data to find who you follow, but doesnt follow you

untruth-instagram-followers Totally *legal* Instagram automation. Crosses a user follower/following data to find who he follows, but that doesn't foll

Oct 12, 2022

A new Flutter package which helps you to implement Ticket Widget in your app.

A new Flutter package which helps you to implement Ticket Widget in your app.

flutter_ticket_widget A new Flutter package which helps you to implement Ticket Widget in your app. The source code is 100% Dart, and everything resid

Dec 22, 2022

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

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

Link Preview Generator A cross-platform flutter package to convert your links into rich beautiful previews. This package is inspired from Any Link Pre

Oct 21, 2022

A Flutter widget to dynamically add links to your text.

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

Dec 15, 2021

Simple Dart package for creating mailto links in your Flutter apps or web pages

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

Jul 8, 2022

Access links between your devices in real time!

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

Aug 5, 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
Releases(0.0.1)
Owner
Ilia Beregovskii
Flutter/.NET dev.
Ilia Beregovskii
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
NearTurf is a turf booking app that helps you find the best turf near you and book more slots. Created by using flutter , Node js

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

Harshad Ok 3 Oct 26, 2022
A lightweight flutter package to linkify texts containing urls, emails and hashtags

linkfy_text A lightweight flutter package to linkify texts containing urls, emails and hashtags. Usage To use this package, add linkfy_text as a depen

Stanley Akpama 14 Nov 23, 2022
Find The Latest trending and upcoming movies and tv shows with MovieDB app. The app contains all info about movies and tv shows. find similar movies or shows, Browse all genres, video trailers, backdrops, logos, and posters.

MovieDB App Features. Dynamic Theming Search Functionality Onboarding-Screen Select favourite movie Home Screen Tranding movie Movies different catego

Ansh rathod 80 Dec 12, 2022
A string generator that helps to implement real-time editing of an ordered sequence.

About A string generator that helps to implement real-time editing of an ordered sequence. It makes reordering, sorting, and interleaving transactions

Minsik Kim 3 May 15, 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

Saad Farhan 23 Dec 17, 2022
Find-Kosan-Cimahi - Find Kosan Cimahi App With Flutter

Find Kosan Cimahi Masih Tahap Belajar Dart This project is a starting point for

null 1 Feb 17, 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
Find out what you did all the days and unlock moments you completely forgot!

This project has been replaced by Relieve Quid Faciam Hodie What did I do today? Find out what you did all these days and unlock moments you completel

null 10 Oct 27, 2022