Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text not arranged correctly when text contain new line #1

Closed
apinprastya opened this issue Oct 28, 2018 · 19 comments
Closed

Text not arranged correctly when text contain new line #1

apinprastya opened this issue Oct 28, 2018 · 19 comments
Labels
bug Something isn't working

Comments

@apinprastya
Copy link

So, when the text contains new lines the text is not correctly arrange.
This text work perfect :
[text] [text with url] [text]

But this one not :
[text] [newline] [text with url] [newline] [text]

@Cretezy
Copy link
Owner

Cretezy commented Oct 30, 2018

Can you provide the code for each of your examples, and screenshots of the results?

@Cretezy Cretezy added question Further information is requested and removed question Further information is requested labels Oct 30, 2018
@apinprastya
Copy link
Author

Hi @Cretezy, sorry for late reply. You can reproduce the bug by edit the example :
please check https:/Cretezy/flutter_linkify/blob/master/example/lib/main.dart#L25

And change the line with this line :
text: "Made by\nhttps://cretezy.com \n Hi Again",

Cretezy added a commit that referenced this issue Nov 5, 2018
@Cretezy Cretezy added the bug Something isn't working label Nov 5, 2018
@Cretezy
Copy link
Owner

Cretezy commented Nov 5, 2018

Fixed! I just published v1.0.2. Thanks for the report!

@Cretezy Cretezy closed this as completed Nov 5, 2018
@apinprastya
Copy link
Author

Hi @Cretezy , it still happening.
screenshot from 2018-11-07 06-59-06

@Cretezy
Copy link
Owner

Cretezy commented Nov 7, 2018

Have you updated? It worked for me, I'll try again when I'm back home

@apinprastya
Copy link
Author

That freshly new clone from github. First I try on my project and update the version to 1.0.2, but it still happening, and then I clone it from github and run the example in case I have problem with my project. But it also happen on example

@Cretezy
Copy link
Owner

Cretezy commented Nov 7, 2018

Alright I'll take another look when I get home. Not too sure what's going on

@Cretezy Cretezy reopened this Nov 7, 2018
@Cretezy
Copy link
Owner

Cretezy commented Nov 7, 2018

Alright pushed v1.0.3 with the fix for this! Was using \s? instead of \s*? for matching whitespace. Let me know how it is!

@Cretezy Cretezy closed this as completed Nov 7, 2018
@apinprastya
Copy link
Author

Hi again @Cretezy, the bug still occure when I have several new lines.
screenshot from 2018-11-10 09-35-18

@lucasjinreal
Copy link

@apinprastya @Cretezy Same issue here, to be specific, some text like this:

1、 牟平区检察院召开检察建议集中公开送达观摩会
https://i.xinwen.cn/158738050434750469.html
2、 最美川藏铁路成雅段开通在即
https://i.xinwen.cn/158622713363045381.html
3、 高官寨街道纪工委三项举措推进“三转”
https://i.xinwen.cn/158553380289009670.html
4、 龙山街道纪工委:不松劲不停步 ,1-6月立案10件
https://i.xinwen.cn/158553379318027274.html
5、 垛庄镇纪委加强扶贫领域监督检查
https://i.xinwen.cn/158553379388281860.html
6、 龙山街道纪工委回访教育让受处分党员干部重拾信心
https://i.xinwen.cn/158553379405038605.html
7、 龙山街道十比十看,提高机关工作效能
https://i.xinwen.cn/158553379466925062.html
8、 龙山街道短信“微提醒” 纪律“牢记心”
https://i.xinwen.cn/158553379367311361.html
9、 章丘龙山街道强力治理“为官不为”
https://i.xinwen.cn/158553379224683536.html
10、 龙山街道抓早抓小,增强党员干部纪律规矩意识
https://i.xinwen.cn/158553379009746961.html
11、 龙山街道用好通报曝光“杀手锏” 持续形成震慑
https://i.xinwen.cn/158553378941589504.html
12、 章丘区纪委到文祖街道开展集中调研活动
https://i.xinwen.cn/158553374918188043.html
13、 章丘区纪委监察委在“大学习、大调研、大改进”中开展“三照三转三改三推”活动
https://i.xinwen.cn/158553374783984651.html
14、 章丘区纪委机关党支部开展谈心谈话活动
https://i.xinwen.cn/158553374575318033.html
15、 章丘区纪委监察委领导到埠村街道督导扫黑除恶专项斗争工作
https://i.xinwen.cn/158553374710563852.html

it contains \n each line, it will render trim \n and place it to end of text:
image

as you can see, original \n are gone, comes to the bottom of text. I am using the newest version......... Any updates on this?

@huulbaek
Copy link

I'm experiencing the same as @apinprastya – any news on this? Or is the issue really closed?

(thanks for the great contribution, btw)

@Cretezy
Copy link
Owner

Cretezy commented Feb 19, 2019

Hey sorry, haven't gotten to fixing this. I'll take a look into it now.

@Cretezy Cretezy reopened this Feb 19, 2019
@Cretezy
Copy link
Owner

Cretezy commented Feb 19, 2019

Update:

image

Pushed out v1.0.4 with the update.

@voivoed
Copy link

voivoed commented Mar 1, 2019

I'm having a simliar issue that might be related to this one so I didn't want to create a new issue. When I have multiple links with \n, only the link on the first line gets humanized (I wrapped the Linkify widget creation in a function). All the links work.

_makeLink(
context,
"Freepik at https://www.freepik.com/\n"
"Daniel Bruce at http://www.entypo.com\n"
"Aristeides Stathopoulos at http://aristeides.com/\n"
"Smashing Magazine at http://designmodo.com/linecons-free/\n"
"Dave Gandy at http://fortawesome.github.com/Font-Awesome/"),

Widget _makeLink(BuildContext context, String textToLink) {
return Linkify(
onOpen: (url) async {
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
},
text: textToLink,
style: TextStyle(color: Theme.of(context).hintColor),
linkStyle: TextStyle(color: Theme.of(context).primaryColor),
humanize: true,
);
}

Returns:

capture

@Cretezy
Copy link
Owner

Cretezy commented Mar 1, 2019

@voivoed I'm not too sure what's wrong with the code you presented.

Are you on the latest version?

Can you give a full code example I can run, and the expected vs actual results?

@voivoed
Copy link

voivoed commented Mar 1, 2019

@Cretezy I'm using the latest version, just created a simple project to test it.

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

void main() {
  runApp(
    MaterialApp(
      title: "Linkify Test",
      home: Home(),
    ),
  );
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Linkify Test"),
      ),
      body: Center(
        child: Linkify(
          onOpen: (url) => print("Clicked $url!"),
          text: "Made by https://cretezy.com\n"
              "Hosted by https:\n"
              "For use with Flutter https://flutter.io",
          humanize: true,
        ),
      ),
    );
  }
}

When I run it, the first "https//" (from cretezy.com) gets removed as per the "humanize" parameter, but the next 2 (github and flutter) stay there. Here's a screenshot:

capture

I would expect to get 3 lines like this, without any "https://":

Made by cretezy.com
Hosted by github.com
For use with Flutter flutter.io

But I'm getting this, only the first "https://" is removed:

Made by cretezy.com
Hosted by https:
For use with Flutter https://flutter.io

@Cretezy
Copy link
Owner

Cretezy commented Mar 3, 2019

Ah yes, that's definitely a bug. I'll take a look soon. We'll track this in another issue though since it's related to this

@Cretezy
Copy link
Owner

Cretezy commented Mar 4, 2019

@voivoed Fixed in v1.1.1!

@voivoed
Copy link

voivoed commented Mar 4, 2019

@Cretezy it's working now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants