simc / auto_size_text

Flutter widget that automatically resizes text to fit perfectly within its bounds.
https://pub.dev/packages/auto_size_text
MIT License
2.06k stars 241 forks source link

How to replace Text.textHeightBehavior? #81

Open 131e55 opened 3 years ago

131e55 commented 3 years ago

Question I had used Text.style.height and Text.textHeightBehavior for line-spacing. (not line-height) However AutoSizeText.textHeightBehavior isn't defined.

How to replace Text.textHeightBehavior? or How to express line-spacing using AutoSizeText?

Code sample Text

const Text(
    'Line 1\nLine2',
    style: TextStyle(
        fontSize: 18,
        height: 1.25,
        color: Colors.black,
    ),
    textAlign: TextAlign.center,
    textHeightBehavior: TextHeightBehavior(
        applyHeightToFirstAscent: false,
        applyHeightToLastDescent: false,
    ),
);

AutoSizeText (can't build)

const AutoSizeText(
    'Line 1\nLine2',
    style: TextStyle(
        fontSize: 18,
        height: 1.25,
        color: Colors.black,
    ),
    maxLines: 2,
    minFontSize: 10,
    textAlign: TextAlign.center,
    // ❌ The named parameter 'textHeightBehavior' isn't defined.
    textHeightBehavior: TextHeightBehavior(
        applyHeightToFirstAscent: false,
        applyHeightToLastDescent: false,
    ),
);

Version