I have arabic text the issue is it randomly breaks at single point and goes to new line even though the space is available around. Below is an example for reference.
All of the arabic text is saved as html definition of decimal character code on ASCII table.
So basically this:
Notice how in console the text is shown completely fine but not on the webapp.
Here's my implementation for the text:
child: AutoSizeText(
functions.getArabicVerion(getJsonField(
qaidaItem2Item,
r'''$''',
).toString().replaceAll(' ', '\u00A0')),
style: Theme.of(context).bodyText1.override(
fontFamily: 'meQuran',
fontSize: double.parse(textSizeValue),
useGoogleFonts: false,
),
If you add u00A0 it will essentially add a space. You can replace it with an empty string instead
replaceAll(' ', '').replaceAll('\n', '');
And remove auto resize widget
It was an issue with flutter, that now has been fixed.
Related
I have a text widget to show the headline. If I have a long headline, which breaks into two lines
Text(
"Heading",
maxLines:2,
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.justify,
)
It works perfectly.
But my requirement is not exactly like this. For long headings, 2nd line should be displayed as 75% of the first line if the length is long . Below I attached the expected result,
You could truncate the first line to the right length and use the rest for the second line. Place both in the RichText Widget and define different styles for each.
In general I would not solve this problem in the code way but talk to the author of the text if possible. This does not sound like the best practice of typography to me.
I am using a plugin
pdf : ^3.7.1
On Using Following Code
pw.Text(Very Long Text,
style: pw.TextStyle(
fontSize: 20,
),
),
The very long text is not going in a new line it's going out of the bound of the page.
As you can see the text is cut after reaching the end. Even on using paragraph same happened.
That happens because that package can't "go inside" a single widget and split it in order to make it fit the page (or, in other cases, to create a new page).
You have to either wrap the text yourself and make it a multiline widget, or split the text yourself (maybe using something like CR or LF as separator) and divide it over different widgets.
Wrap your Text in SizedBox and give it a width
I'm having some troubles with Flutters Text widget wrapping the text at odd locations if there isn't enough space to display it in a single line:
Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text("Ready to Grow? Click to join the Tribe!",
style: Theme.of(context).textTheme.headline2,
textAlign: TextAlign.center,
)
],
),
)
In certain situations my text wraps as follows:
Ready to Grow? Click to join the Tribe
!
This looks quite ugly and I would like Flutter to wrap the line only at white spaces - how can I achieve that? I already tried softWrap and the overflow property but they don't seem to have any impact on the described behaviour...
Real world screenshot (notice the trailing "!" at the very bottom):
I find it quite interesting that you would ask this question, because I've seen a lot of people complaining about the opposite! In general, Flutter is very aggressive about "only wrap words at boundaries", almost too strict, so usually the complain I hear is: "how to make Flutter change line mid-word".
To demonstrate what I mean, look at the following GIF:
From the GIF, we can observe that, Flutter already treats "text!" and "boundaries!" as single words. It tries its best to avoid breaking between the letters and the "!" mark. When needed, it puts the whole word "boundaries!" into its own line.
However, when the screen size is too narrow, it cannot possibly fix the whole word (again, "boundaries!" is treated as a single one word), it will have to break it. Depending on the screen size, line break could happen at any point.
So overall, Flutter is doing a pretty great job on this regard. You could try to design your UI and draft your copy in a way that avoid using words that are longer than a typical screen width.
I'm actually trying to clone an Insta page. How do I remove the space between two texts inside a column in Flutter pointed with a green arrow in the screenshot? The upper text "6,667" had to be bold so I had to separate it with "Posts".
Please see the screenshot here:
for line spacing use height property in TextStyle
Text('Hello World', style: TextStyle(height: 1.0 // change this as you want
))
Remove the \n in \nPosts Text Widget
The issue is in your 2nd Text("\n Posts");
Please, remove the \n from the text and it will be okay
Hello and thanks for any help, I'm trying to put an ellipsis at the end of a paragraph, it seems so easy to do in Flutter... but, in my case, it doesnt work with ellipsis.
It works as expected with TextOverflow.clip & TextOverflow.fade, I tried everything (put inside fixed container, flexible container...), and every, supossedly, working code I found seem to not work in my case, maybe a bug of 1.9? I have something like this:
Text(
'Tree lines text for demostration puropuse,tree lines text for demonstration purpose, lines text for demostration puropuse',
overflow: TextOverflow.ellipsis,
maxLines: 3,
),
It works great with Text Overflow.clip & Text Overflow.fade but, with exactly the same environment, it doesn't work with Text Overflow.ellipsis.
The thing is you do not have required character to show elipsis. In another word, as name suggest your text is not overflowed to show elipsis. So, try by reducing maxLines: 3, to 1.
If you have specific character limit, you can check for the text length and add few dots by substring the text(And of course this is not preferable solution).