granoeste
granoeste

Reputation: 1651

How to autosizing TextWidget in Flutter

I want to set auto-size to TextWidget in Flutter.

It's like Autosizing TextViews | Android Developers https://developer.android.com/guide/topics/ui/look-and-feel/autosizing-textview.html

Does Flutter support it? How to implement auto-sizing TextWidget?

Upvotes: 4

Views: 1957

Answers (2)

granoeste
granoeste

Reputation: 1651

I could implement it using FittedBox.

new FittedBox(
    fit: BoxFit.contain,
    child: new Padding(
        padding: const EdgeInsets.all(8.0),
        child: new Text(
            'LooooooooooooooooooooooooooooooooooooooooooooongText',
        ),
    ),
),

Upvotes: 2

Arnold Parge
Arnold Parge

Reputation: 6867

You can puy your TextWidget inside Fexible Widget. Flexible Widget automatically gives it's child the available space.

Upvotes: 2

Related Questions