ellipsis_overflow_text 1.0.1+1 copy "ellipsis_overflow_text: ^1.0.1+1" to clipboard
ellipsis_overflow_text: ^1.0.1+1 copied to clipboard

Flutter widget that automatically sets the number of lines to be shown on a text with the Ellipsis text overflow type.

ellipsis_overflow_text #

Version GitHub license

Flutter widget that automatically sets the number of lines to be shown on a text with the ellipsis overflow type.

Show some 💙 and star the repo to support the project

Inspired and based on the AutoSizeText package.

Resources: #

Contents #

Usage #

Common use #

EllipsisOverflowText behaves exactly like a Text. The only difference is that it automatically sets the number of lines to be shown on a text with the ellipsis overflow type.

EllipsisOverflowText(
  'Some text here',
  style: TextStyle(fontSize: 22),
)

Showing ellipsis on break line overflow #

For showing an ellipsis overflow when the last rendered text line ends with a break line, you can set the showEllipsisOnBreakLineOverflow property to true.

Default behavior:

EllipsisOverflowText(
  'First String here\n'
  'This String will fit the given bounds.',
  style: TextStyle(fontSize: 22),
)

image

With showEllipsisOnBreakLineOverflow equals to true.

EllipsisOverflowText(
  'First String here\n'
  'This String will fit the given bounds.',
  showEllipsisOnBreakLineOverflow: true,
),

image

Parameters #

Parameter Description
data* The String text to be shown.
key* Controls how one widget replaces another widget in the tree.
textKey The inner Text Widget key.
locale* Used to select a font when the same Unicode character can be rendered differently, depending on the locale.
maxLines An optional maximum number of lines for the text to span.
semanticsLabel* An alternative semantics label for this text.
selectionColor* The color to use when painting the selection.
softWrap* Whether the text should break at soft line breaks.
strutStyle* Defines the strut, which sets the minimum height a line can be relative to the baseline.
style* If non-null, the style to use for this text
textAlign* How the text should be aligned horizontally.
textDirection* The directionality of the text. This decides how textAlign values like TextAlign.start and TextAlign.end are interpreted.
textHeightBehavior* Defines how to apply [TextStyle.height] over and under text.
textScaleFactor* The number of font pixels for each logical pixel.
textWidthBasis* The different ways of measuring the width of one or more lines of text.
showEllipsisOnBreakLineOverflow Whether the last rendered text line should ends with ellipsis overflow when the last character is a breakline, i.e. "\n".

Parameters marked with * behave exactly the same as in Text

Performance #

EllipsisOverflowText is really fast. In fact, you can replace all your Text widgets with EllipsisOverflowText.

Troubleshooting #

Missing bounds #

If EllipsisOverflowText overflows or does not replace the text with ellipsis characters, you should check if it has constrained width and height.

Wrong code:

Row(
  children: <Widget>[
    EllipsisOverflowText(
      'Here is a very long text, which will use ellipsis in case the text overflows',
    ),
  ],
)

Because Row and other widgets like Container, Column or ListView do not constrain their children, the text will overflow.
You can fix this by constraining the EllipsisOverflowText. Wrap it with Expanded in case of Row and Column or use a SizedBox or another widget with fixed width (and height).

Correct code:

Row(
  children: <Widget>[
    Expanded( // Constrains EllipsisOverflowText to the width of the Row (You could use Flexible instead).
      child: EllipsisOverflowText(
        'Here is a very long text, which will use ellipsis in case the text overflows',
      )
    ),
  ],
)
}

Further explanation can be found here, the question is about the AutoSizeText package, but the answer is the same for this package. If you still have problems, please open an issue.

MIT License #

Copyright (c) 2022 Vitor Lucas (Reiko-Dev)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7
likes
150
points
12
downloads

Publisher

verified publisherreikodev.com

Weekly Downloads

Flutter widget that automatically sets the number of lines to be shown on a text with the Ellipsis text overflow type.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ellipsis_overflow_text