0

If I have a long headline, which breaks into two lines depending on length of the String, the body text is not clipping correct inside the Container widget

enter image description here

Expanded(
 child: Container(
   height: MediaQuery.of(context).size.height / 7.5,
   padding: EdgeInsets.only(right: 8),
   child: Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      mainAxisAlignment: MainAxisAlignment.start,
      children: [
        Text(
          'HERE SOME LONG HEADLINE, WITH 1 or 2 Lines'
       
          maxLines: 2,
          overflow: TextOverflow.ellipsis,
        ),
        SizedBox(
        height: 3.0,
        ),
        Expanded(
         child: Text(
           'here some long body text over more lines, which is cut wrong when the headline is two lines',
           overflow: TextOverflow.ellipsis,
           softWrap: true,
           maxLines: 5,
           textAlign: TextAlign.left,
         ),
        ),
      ],
    ),
  ),
),
th_lo
  • 461
  • 3
  • 18

1 Answers1

0

I believe some widget wrapping your Text widgets, is limiting the amount of space they have, hence the clipping. Without the full widget tree, it's not possible to be sure which.

Your containing Container widget has a height specified. If you remove this, do your text widgets still clip?

Expanded(
 child: Container(
   height: MediaQuery.of(context).size.height / 7.5, // ← try removing this
   padding: EdgeInsets.only(right: 8),

Also, perhaps this package might be interesting: AutoSizeText.

Baker
  • 24,730
  • 11
  • 100
  • 106
  • yes, then it clips on the boundaries of the Container higher in the widget tree... all the Container should have the same height. sometimes the headline is 2 lines and sometimes only 1. when the headline is only 1 line the text gets clipped correct – th_lo Feb 22 '21 at 18:19
  • added a new screenshot – th_lo Feb 22 '21 at 18:26