MBK
MBK

Reputation: 3414

fittedbox with maximum two lines in flutter

Container(
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 60),
        child: Text(
          //  subCategoryName,
          "This is a very Long Text takes more space",
          textAlign: TextAlign.center,
          maxLines: 2,
          overflow: TextOverflow.fade,
          style: Theme.of(context)
              .textTheme
              .headline3
              .copyWith(color: Colors.white, fontSize: 32),
        ),
      ),
    ),

Look this Picture

I need this line to be a maximum of two lines and shrink the size like a FittedBox (with BoxFit.fitWidth) if the text gets even longer

When I used the FittedBox it looking like this. But I need to take it up to 2 lines if needed.. Any solution is appreciated

Upvotes: 10

Views: 7443

Answers (1)

MBK
MBK

Reputation: 3414

Got it working by the reply of Sam Chan. I used the AutoSizeText Package

Upvotes: 8

Related Questions