Text Overflow inside ROW widget doesn't work

Issue

So I tried to put a text after an icon, so i use Row. But when I input the long text it does overflow the SizedBox. so i add TextOverflow, but the Textoverflow didn’t work

Here’s the code :

Row(
children: [
  Icon(
    Icons.location_on,
    size: 2.h,
    color: Color(0xFFE32346),
  ),
  Padding(
      padding: EdgeInsets.only(left: 1.h),
      child: Text(
        Address,
        overflow: TextOverflow.ellipsis,
        maxLines: 1,
        style: TextStyle(
            color: Colors.black,
            fontSize: 16.sp,
            fontFamily: 'Poppins'
        ),
      )
  ),
]),

Solution

this is the example . please use Expanded in this use case

like this way

 Row(children: [
              Icon(
                Icons.location_on,
                size: 20,
                color: Color(0xFFE32346),
              ),
              Expanded(
                  child: Text(
                 '     qqqqqqqqqqqqqq qqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq',
                overflow: TextOverflow.ellipsis,
                maxLines: 1,
                style: TextStyle(
                    color: Colors.black, fontSize: 16, fontFamily: 'Poppins'),
              )),
            ]),

the output will be

enter image description here

Answered By – Jinto Joseph

Answer Checked By – Senaida (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *