chichi
chichi

Reputation: 3302

Flutter: BoxFit.scaleDown but set the text at its start of the container

 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?

Upvotes: 0

Views: 1143

Answers (1)

Kaushik Chandru
Kaushik Chandru

Reputation: 17802

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 
      ),
    ),
  ),

Upvotes: 1

Related Questions