Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 910
MBK Avatar asked Apr 29 '26 19:04

MBK


1 Answers

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

like image 121
MBK Avatar answered May 01 '26 10:05

MBK