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
269 stars 101 forks source link

Links sometimes get extra newline inserted into the text #76

Open augb opened 3 years ago

augb commented 3 years ago

With 4.0.2:

Screen Shot 2021-03-02 at 9 56 43 AM Screen Shot 2021-03-02 at 9 56 27 AM

With 4.1.0:

Screen Shot 2021-03-02 at 10 00 11 AM Screen Shot 2021-03-02 at 10 00 24 AM

Example code where this happens:

var card = Card(
  shape: RoundedRectangleBorder(
    borderRadius: BorderRadius.circular(6.0),
  ),
  elevation: 8.0,
  margin: new EdgeInsets.symmetric(horizontal: paddingHorizontalValue),
  child: Padding(
    padding: const EdgeInsets.all(20.0),
    child: Linkify(
      linkStyle: TextStyle(
        color: Colors.blue,
        decoration: TextDecoration.underline,
      ),
      onOpen: _onOpen,
      options: LinkifyOptions(
        defaultToHttps: true,
        humanize: false,
        removeWww: false,
        excludeLastPeriod: true,
        looseUrl: false,
      ),
      text:
          'Please visit this website for more detailed detail: https://www.google.com.',
      style: TextStyle(fontSize: kNormalTextSize),
    ),
  ),
);

And, for completeness:

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