link 1.1.0

Link #

Just a simple link-alike widget for Flutter #

Although simple, Flutter lacks a linkable widget out of the box, so I decided to build my own. No fancy code, but it does its job. That's all I asked.

It uses an InkWell widget to provide both some visual response to the tap event and a trigger to launch the URL (onTap).

It's not intended to open up all kinds of URLs; it basically depends on your device. But you can be certain http:// and https:// URL will be launched (every device ships a webkit). Instead of throwing an error in case the URL can't be opened, you can use the onError callback at the constructor and do whatever you want to do. I really wanted to keep it simple.

For the launching part, I took the url_launcher package available at Dart Pub. A nice, working library I've used in almost every project since I learned about it.

Almost forgot... no idea whether it works on iOS. For the time being, I haven't yet set up the environment ;P. Maybe someday.

Documentation #


You can find the url_launcher Flutter package at Dart Pub, where I plan to submit this very library.

Let's give it a try #


Include link in your pubspec.yaml file:

    sdk: flutter
  link: ^1.0.0

If your IDE doesn't do it automatically, type:

flutter packages get


Import the package in your dart file and use Link to get the actual icon widget:

import 'package:link/link.dart';
Link _link = Link(
  child: Text('A link'),
  url: '',
  onError: _onErrorCallback

OnError is not required and defaults to null, meaning that, in case URL can't be launched, nothing will happen. No error, no alert, nothing.


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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
      home: MyHomePage(title: 'Link Demo Home Page'),

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {

  void _showErrorSnackBar() {
        content: Text('Oops... the URL couldn\'t be opened!'),

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      body: Center(
        child: Link(
          child: Text('This is a link to Flutter'),
          url: '',
          onError: _showErrorSnackBar,

GitHub source code #

If you're interested on the code (feel free to modify it anyway you want), you can find it here:

1.0.0 #

  • Initial version

1.1.0 #

  • Fixed a bug: URL didn't open within the app, but in browser. Solved already

Use this package as a library

1. Depend on it

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

  link: ^1.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:link/link.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 Feb 18, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health suggestions

Fix lib/src/link_base.dart. (-0.50 points)

Analysis of lib/src/link_base.dart reported 1 hint:

line 13 col 66: Don't explicitly initialize variables to null.

Format lib/link.dart.

Run flutter format to format lib/link.dart.

Maintenance suggestions

The package description is too short. (-13 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and link.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
url_launcher ^5.0.2 5.4.1
Transitive dependencies
collection 1.14.11 1.14.12
flutter_web_plugins 0.0.0
meta 1.1.8
plugin_platform_interface 1.0.1
sky_engine 0.0.99
typed_data 1.1.6
url_launcher_macos 0.0.1+2
url_launcher_platform_interface 1.0.5
url_launcher_web 0.1.1
vector_math 2.0.8
Dev dependencies
test ^1.0.0