text_autosize 0.3.1
text_autosize: ^0.3.1 copied to clipboard
Automatically resize text to fit its bounds: shrink the font until the text fits the available width, height and maxLines. TextScaler-aware, API-compatible with auto_size_text.
0.3.1 #
-
Correct the description of the 0.3.0 fix. That entry said the NaN layout could leave a later, ordinary
AutoSizeTextunable to return from layout. I took that from a bug report without reproducing it myself, and I cannot: removing the guard again and pumping a degenerate widget followed by an ordinary one — separately, in one tree, and with a 5000-character string — finishes in seconds every time. The claim was not mine to make and it is withdrawn.What 0.3.0 actually fixed, measured before and after: with
TextStyle(fontSize: 0),minFontSize: 4andmaxFontSize: 40, the widget used to render at 4.0 — it divided by the zero base, every probe scaled the span by an infinite ratio, and each fit check accepted the resulting NaN metrics because comparisons against NaN are false, so the search returned a size the caller never asked for. It now renders at 0.0, which is exactly what a plainTextdoes with the same style. Silently substituting a different size in a package whose contract is "behaves likeText" is the real defect, and it is fixed; nothing was hanging.
0.3.0 #
- Fix a hang reachable from a legal style.
TextStyle(fontSize: 0)— which a plainTextrenders without complaint — made every fit probe scale the span bycandidate / 0. The resulting infinite ratio laid out text at NaN sizes, and because each fit check compares against NaN (where every comparison is false) the probe reported that it fitted. Worse than the wrong answer, that NaN layout left the text engine in a state where a later, ordinaryAutoSizeTextcould stop returning from layout entirely. A zero, negative or infinite base now skips the ratio machinery and renders at the size the caller asked for, which is whatTextdoes. Covered by tests, including one that pumps an ordinary widget afterwards to prove nothing is wedged. - Mark
AutoSizeGroupasfinal. Its entire contract is private, so an externalimplements AutoSizeGroupcompiled but was guaranteed to fail withNoSuchMethodErrorthe moment a widget used it.AutoSizeTextis deliberately left open: it is a drop-in forauto_size_text, whoseAutoSizeTextis open, as is Flutter's ownText, and subclassing a text widget to preset its style is a real pattern this should not break. - Remove a stray
# Changelogheading from the middle of this file.
0.2.0 #
- Add back a deprecated
textScaleFactorparameter onAutoSizeTextandAutoSizeText.rich. The 0.1.0 release dropped it, which broke the drop-in claim: any call site that settextScaleFactorfailed to compile. It now compiles again and maps toTextScaler.linear(factor). PrefertextScaler;textScaleFactoris deprecated and will be removed later. Setting both asserts in debug builds.
0.1.3 #
- Install instructions now say
pub addinstead of pinning a version. The pinned number was stale by several releases and would have been stale again after the next one: the README ships frozen in the archive, so a hand-edited version line is wrong the moment anything is published. This one cannot go out of date.
0.1.2 #
- Docs: tightened the README wording and visuals.
0.1.1 #
- Expand the package description to name what the package does in the words people search for. No code changes.
0.1.0 #
Initial release. The API follows auto_size_text 3.0.0, with these changes:
textScalerreplacestextScaleFactor. The fitted font size accounts for the ambientMediaQueryscaler, including nonlinear scalers.- Rich text is measured with the fully resolved style, matching how
Text.richrenders it. - Measurement resolves
textAlignandtextDirectionlike the renderedTextinstead of assuming left-aligned, left-to-right text. - A single
TextPainteris reused for all fit measurements of a widget. textWidthBasis,textHeightBehaviorandselectionColorare passed through to the builtText.presetFontSizesare asserted to be in descending order.