1

I am struggling to make this work but I tried everything and still, I can't make this work. So, I have the structure below:

Row(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: <Widget>[
      CircleAvatar(
        radius: 40.0,
        backgroundImage: Image
            .network(
          '$thumbnail',
          fit: BoxFit.cover,
        )
            .image,
      ),
      SizedBox(
        width: 20,
      ),
      Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            'Really biiiig drink name here',
            style: TextStyle(
              color: Colors.white,
              fontSize: 28
            ),
          ),
          Text(
            'Category goes here',
            style: TextStyle(
              color: Colors.white.withOpacity(.8)
            ),
          ),
        ],
      ),
    ],
  ),

And it renders like this:

overflow

How can I clip, or wrap that title text without defining a fixed width to a parent widget?

Thiago Hencke
  • 301
  • 2
  • 11

3 Answers3

2

Use Expanded widgets to resist overflow of view

enter image description here

Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  CircleAvatar(
                    radius: 40.0,
                    backgroundImage: Image.network('https://i.stack.imgur.com/LJ30b.png', fit: BoxFit.cover,).image,
                  ),
                  SizedBox(
                    width: 20,
                  ),
                  Expanded(child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        'Really biiiig drink name here',
                        style: TextStyle(
                            color: Colors.yellow,
                            fontSize: 28
                        ),
                      ),
                      Text(
                        'Category goes here',
                        style: TextStyle(
                            color: Colors.red.withOpacity(.8)
                        ),
                      ),
                    ],
                  ), ),

                ],
              ),
Farhana Naaz Ansari
  • 7,524
  • 26
  • 65
  • 105
0

Add Expanded to your inner Column to give it a defined width.

Row(
  crossAxisAlignment: CrossAxisAlignment.start,
  children: <Widget>[
    CircleAvatar(
      radius: 40.0,
      backgroundImage: Image.network(
        '$thumbnail',
        fit: BoxFit.cover,
      ).image,
    ),
    SizedBox(
      width: 20,
    ),
    Expanded(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            'Really biiiig drink name here',
            style: TextStyle(
              color: Colors.white,
              fontSize: 28
            ),
          ),
          Text(
            'Category goes here',
            style: TextStyle(
              color: Colors.white.withOpacity(.8)
            ),
          ),
        ],
      ),
    ),
  ],
);
Michael Yuwono
  • 2,452
  • 1
  • 14
  • 32
0

If you add an Expand to where the overflow is taking place it should solve the problem.

Bnd10706
  • 1,933
  • 5
  • 24
  • 39