Home > Software engineering >  Flutter: BoxFit.scaleDown but set the text at its start of the container
Flutter: BoxFit.scaleDown but set the text at its start of the container

Time:06-28

 Container(
    width: 200,
    color: Colors.blue,
    child: FittedBox(
      fit: BoxFit.scaleDown,
      child: Text(
        'hiiiiii',
        overflow: TextOverflow.ellipsis,
      ),
    ),
  ),

I have this widget that looks like

enter image description here

But, I want to set it to the beginning of the container like when I do not use FittedBox widget.

enter image description here

Is there any way that I can use FittedBox's BoxFit.scaleDown and put the text in the beginning?

CodePudding user response:

Try this

Container(
   alignment : Alignment.leftCenter, //add alignment to fitted box
    width: 200,
    color: Colors.blue,
    child: FittedBox(
      fit: BoxFit.scaleDown,
      child: Text(
        'hiiiiii',
        overflow: TextOverflow.ellipsis,
        textAlign: TextAlign.start //add left align to text content too 
      ),
    ),
  ),
  • Related