flutter_linkify icon indicating copy to clipboard operation
flutter_linkify copied to clipboard

Multiline text

Open jeanmatthieud opened this issue 4 years ago • 7 comments

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 avatar Mar 02 '21 16:03 jeanmatthieud

I also tried the sample content Made by https://cretezy.com\n\nMail: [email protected], and it doesn't work as expected.

jeanmatthieud avatar Mar 02 '21 16:03 jeanmatthieud

Works fine with 3.1.3

jeanmatthieud avatar Mar 02 '21 17:03 jeanmatthieud

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!)

andrea-h10 avatar Mar 05 '21 15:03 andrea-h10

Works fine with 3.1.3

With 3.1.3 alos it doesn't work for me.

sisirkp avatar May 04 '21 18:05 sisirkp

not accepting \n (new line).

softuvo avatar May 10 '21 07:05 softuvo

Hi For the time being you can use his hack. It's working for me

String getFinalString(String text) { var finalString = ""; if (text.contains("\n")) { var des = text.split("\n"); des.forEach((desc) { finalString = finalString.isEmpty ? finalString + desc : finalString + " \n" + desc; }); } else finalString = text;

return finalString;

}

softuvo avatar May 13 '21 04:05 softuvo

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,
  ),
);

}`

sisirkp avatar May 15 '21 10:05 sisirkp