optimal_wrap_text
1.5.0, released 3 months ago by commingle.app
A Text widget replacement that automatically finds optimal line breaks for balanced multi‑line text.
What it does
It measures the available width and uses a binary search to determine the narrowest width that keeps the text on the same number of lines, then renders the text at that width. It works with plain Text and RichText, including WidgetSpans.
AI-written summary of version 1.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need short footnotes, captions or messages that should look visually balanced across lines.
- You want a drop‑in replacement for Text that handles optimal wrapping without manual \n characters.
Skip it when
- Rendering large bodies of text where the extra layout calculations add noticeable overhead.
- Using the widget inside slivers that rely on intrinsic sizing (e.g., SliverFillRemaining).
- Performance‑critical UI where every layout pass must be minimal.
Strengths
- Automatic optimal line breaking without manual effort
- Supports all standard Text properties and RichText features
- Provides minLines and shrinkWrap options for flexible layouts
Weaknesses
- Adds extra layout passes which can affect performance on very long texts
- Does not work inside certain slivers that depend on intrinsic sizing
- Limited to relatively short texts; not a full replacement for scrolling paragraphs
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 0
OptimalWrapText(
'My slightly longer text that will span 2 or 3 lines',
)Alternatives
Packages that do the same job and could replace optimal_wrap_text.
- selectable
A widget that enables text selection across multiple text widgets.
77Compare - re_editor
A lightweight text and code editor widget for Flutter with syntax highlighting and folding.
80Compare - marquee_widget
A Flutter widget that scrolls text and other widgets with RTL support.
47Compare - side_sheet
Implements side sheets for all platforms and responsive UI.
47Compare