Cretezy / flutter_linkify

Turns text URLs and emails into clickable inline links in text for Flutter
https://pub.dartlang.org/packages/flutter_linkify
MIT License
263 stars 99 forks source link

SelectableLinkify - links not working #38

Closed andrea-h10 closed 4 years ago

andrea-h10 commented 4 years ago

I've got it working fine using the Linkify widget.

BUT when I use SelectableLinkify: links still show using the link style (blue underline) BUT links no longer load when clicked.

Thank you!

code to replicate:

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

class TestingScreen extends StatefulWidget {
  @override
  _TestingScreenState createState() => _TestingScreenState();
}

class _TestingScreenState extends State<TestingScreen> {
  _launchURL(String url) async {
    if (await canLaunch(url)) {
      await launch(url, forceWebView: true);
    } else {
      throw 'Could not launch $url';
    }
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      body: SafeArea(
        child: Center(
          child: SelectableLinkify(
            onOpen: (link) {
              _launchURL(link.url);
            },
            text:
            'I have an awesome website https://google.com',
          ),
        ),
      ),
    );
  }
}
Cretezy commented 4 years ago

Please upgrade your Flutter with flutter upgrade

https://github.com/Cretezy/flutter_linkify/issues/31