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

Multiline text #77

Open jeanmatthieud opened 3 years ago

jeanmatthieud commented 3 years ago

Multiline text doesn't work as expected.

Tested on 4.0.2 and 4.1.0.

          Linkify(
            onOpen: (link) async => await canLaunch(link.url) && await launch(link.url),
            text: channel.description,
            options: LinkifyOptions(
              defaultToHttps: false,
              humanize: false,
              removeWww: false,
              excludeLastPeriod: false,
              looseUrl: false,
            ),
          ),

Input text in the text field, displayed text at the bottom of the screen

image

jeanmatthieud commented 3 years ago

I also tried the sample content Made by https://cretezy.com\n\nMail: example@gmail.com, and it doesn't work as expected.

jeanmatthieud commented 3 years ago

Works fine with 3.1.3

andrea-h10 commented 3 years ago

I'm having the same problem... if there are new lines in the text input, the linkified text output is displayed all over the place, not even in the right line order.

I can't downgrade to 3.1.3 because that is not properly handling the excludelastperiod property... so every word at the end of a sentence is being linkified. Rather in a bind here... thanks so much.

(but thanks so much for creating the code package... super helpful! Albeit right now I can't release my app because of this bug... would really appreciate any help!)

sisirkp commented 3 years ago

Works fine with 3.1.3

With 3.1.3 alos it doesn't work for me.

sisirkp commented 3 years ago

For me @softuvo 's solution also didnt work. However, I extended his solution and created a different version of it. This should work in all cases:

`Widget _buildLineSeparatedLinkableTexts(String text) { var textLines = text.split("\n"); final lineTexts = textLines.map((line) { return Padding( padding: const EdgeInsets.only(bottom: 5.0), child: Linkify( onOpen: _onOpen, text: line, style: TextStyle( fontSize: 16.0, color: Colors.white, ), ), ); }).toList();

return SingleChildScrollView(
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: lineTexts,
  ),
);

}`