How to render a "View More" link if text in a widget is too long to fit in a specified nr of lines - flutter

I am working on an app with a chat feature that shows messages in a ListView. The size of each "message" depends on the amount of text in that particular message.
I would like to put a limit on the number of lines, say 10 lines max. If a particular message happens to take up more than the limit, the text should be truncated near the end of the 10th line and a "FlatButton" with the text 'more...' be provided, which allows the user to open up that message to see all the text. For messages that fit, this button will not be shown.
The part I am struggling with is being able to truncate the text at the right point.
Currently I am thinking that guessing the number of lines a message might take up based on the number of characters and the font size would be the best approach, with the limitation that sometimes it might be off by a couple of lines. That is probably acceptable in this application.
As a bonus I also would like to render the "more..." button "inline" at the end of the text, but that is probably a separate question.

Did you try the maxLines property of Text widget? This in combination with overflow should solve your problem.
Reference
maxLine property
overflow property

Related

Adding line counter to a text field

I want to add a line counter to a textfield for a sort of text editor. Looking around, I've seen that a lot of questions on this topic are either unanswered, or do not answer in a satisfactory manner. Something like this How to add prefix widget on every new line in textfield in flutter? asks fundamentally the same question I am, however the only answer there is to create a new widget for each line.
This is one method that could be used, where I add new textfields in a list and build them in a row with their respective line number. However, this means I cannot have those textfields function on more than one line, and I will need to add more textfields each time a user wants to add enough text to make it overflow. The biggest flaw I see with this, though, is that it makes it harder (if not impossible?) to easily select and edit text as you would expect from a text editor, such as using the built in systems for a textfield.
Now, for my solution I am using https://pub.dev/packages/extended_text_field as a way to gain some functionality that I don't really want to take the time to figure out how to do on my own (embedded onClick callbacks for text), so it would be ideal if I could continue to use that without having to fork or even have to figure out how to write my own version.
The primary issue I'm running into is not necessarily getting the number of lines, which can be found using some solutions from How can I add line numbers to TextField on Flutter?, but rather how and where to show those line numbers.
As above, it's not really ideal to pair some number alongside a textfield and create a new textfield for each expected line. What would be ideal, however, is something like , where each line number is prefixed to the line built by the text field. For example, like this: . Something like the solution proposed in Add a prefix to every line in a multiline Text Input in Flutter? would not work especially well, because the solution there is to literally add string values to the textfield, which would require systems to clean the text, in addition to causing an unexpected ability to actually change the numbers (or other line prefix) by the user.
So -- is there any way to implement a line prefix for each line in a textfield? Would it be possible to override an InputDecoration (which allows creating the individual line prefix, but nothing more) to create a line prefix for each line drawn by the textfield? If not, exactly what would be needed to create this? I am familiar with flutter, but I am not quite as familiar with the lower level API's.

Fillable Pdf multi-line, Allow rich text formatting in Acrobat Pro DC: but it ignores line spacing/leading set in More

I'm on Win10, using Acrobat Pro DC 2021.011... to edit and Reader DC (same version) to test.
From experience and from reading forums etc, forms in these apps are maddening... but I have not been able to find any discussion (or solutions) to the following behavior...
The form I'm building for other employees' use has a large edit text box set to Multi-line and Allow Rich Text Formatting. It is set to a default font, Calibri and size 50pt. For most situations this will work for them; provides 2-3 lines for a short product description. But occasionally they want a smaller font and more lines... They know how to get the ctrl+e properties bar. But in my testing of this alternative situation they'll need sometimes, I'm finding it's impossible to get the smaller font size and more lines to work. Here's my process.
tab into text box. Ctrl+E for properties bar.
before typing I set the font size to 24
then I type in my 4 lines of text
then I tab to my next form field...
and kaboom... the field I just filled...it's line height is so large it's pushed some of the content invisible. I assume this is coming from the field's default font size, 50
And if I try to adjust the line height, by selecting all the text and then choosing in More...>Form Field Text Properties>Paragraph>Line Spacing
If I set it to Single and click Close/click into another field I get the very large leading (presumably for 50pt font (same as pic above after point 5)
If I choose Exactly and set to point size slightly larger, click Close/out of field, I get another ridiculous result where the 2/3 line have the height I set, but the space between the 1 & 2 second line is way too much and the space between the last line and 3rd line is way too small...
before tabbing or clicking out of field to another field
Good lord.. what is that! 3 different leading values in the same field; just after applying 1 value to all lines, all text in the field...
It makes no sense... it doesn't look like it regards your input at all, and just comes up with it's own random leading... I've fiddled with Space before/after and combinations of Line Height and nothing comes close to what we need... At this point I'm convinced the Acrobat tools for a stylizing text in a multi-line, allow formatting text field are useless. I'd be better off with my employees they can't format anything, ever. Just type one line and hit Tab or Enter...
What is going on! I'm trying to make a simple fillable form for other employees to use, but this kind of behavior makes that impossible (It's enough of a stretch to teach them to use the ctrl+E and do some styling of their text but this is bonkers and completely unteachable... there's not rhyme or pattern to teach!)
Hope someone can help or has seen this behavior too.

Watch App - Replace ... when text is too long

I have a problem with the size of my text.
When my text is too long in a WKInterfaceLabel, no problem, I just add line or I pass line at 0 to increase automatically the number of lines.
But with WKInterfacePicker, impossible to increase the number of line and I have "..." at the end of my text.
Do you have solutions to display all my text or, at least, to delete this "..." and replace it by some letters more from my text. I work with Swift.
For the second solution, I prefer have "My text" than "My te..."
Sadly, this is not possible. Apple doesn't provide any sort of way on managing that.
A possible, but rather complicated solution would be making a costume picker with labels with multiple lines and using the newly implemented WKCrownSequencer as well as the WKCrownDelegate in watchOS 3 to detect the state of the digital crown. The default picker animations might be impossible or very difficult to reproduce, but it might fix your problem.
try this set in size width = size to fit width content

How to remove empty space after last row when using Can Grow option on text fields in Crystal Report?

I have a report displaying rows with text fields with variable length (I use the Can Grow option). I use a Box for the details. My problem is that when the last text field cannot fit into to the box on the bottom of the page, a empty space is left, and the new row begins on next page. Unchecking the option Keep Object Together on the fields, didn't solve the problem and if it did I don't want the content of the text field to break across pages.
My question is: Is it possible to auto-re-size box height depending on rows content, so I can avoid empty spaces at the bottom on every page (doesn't look very nice).
Thanks in advance.
There are three things I can think of that might help.
As you said, you can limit the maximum size of a "can grow" field. To the right of the can grow checkbox (in CR designer) there is a "Maximum number of lines" value that defaults to 0 (no limit). You can set that to however many lines you like.
The details section itself has a setting for "keep together" too -- right-click the details section label and go to the section expert. If you uncheck it there the details section will start on the bottom of the page and continue on the next one.
Look at the page footer section, it is printed at the bottom of each page, and if it is large, it takes away from the available space for the data. Group footers, if you have any, could give you the same problem.

Detail band longer than necessary in iReport

I have a detail band with text fields and a table. In the designer view I have fit all the band, but when I see the preview the lowest text field is higher than the first text field in the next band (i.e. I have empty space between band 1 and band 2).
The empty space is due by the table, in fact if I remove it I have no empty space. Below the designer view and preview.
The question is: how I can avoid the empty space between the bands? Thanks.
EDIT2: Now that the report is shown, it's clear. Make the table bigger in the report layout. Stretch it all the way to the bottom. When you don't, JR is careful to include as much space below it as you have left there.
EDIT: I think the key issue is that the band height should be "20" to match the height of the elements in it.
Old answer containing trivia that might or might not matter:
Some of your "text fields" are textFields. This is good. Some of your "text fields" are staticText. This is bad. Convert the static text to real text fields. You can right-click them and automatically transform them.
stretchType is bad. Turn that off. (Actually, it's good and useful... but it's not what you want.)
isStretchWithOverflow is good. Turn it on. Your text says that it's already on, but your code shows that it is not.
isPrintWhenDetailOverflows is bad. Turn it off. Your text makes no mention of it, but your code shows that it is on. (It's probably irrelevant... but you should turn it off to be clear that it's not what you think it is.)