flutterdarttext-widget

TextOverFlow.ellipsis in Widget Text not work


enter image description here

my widget text Wrap inside Expanded, row, and Column

return Container(
          child: Expanded(
            flex: 9,
            child: GestureDetector(
              onTap: () {
                // .......
              },
              child: Container(
                color: Colors.transparent,
                child: Row(
                  children: <Widget>[
                    Padding(
                        padding: EdgeInsets.only(top: 15, bottom: 15),
                        child: Container(
                          width: 2,
                          color: Color(0XFF2B9FDC),
                        )),
                    Padding(
                      padding: EdgeInsets.only(left: 15),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text( item.name,
                            overflow: TextOverflow.ellipsis,
                            maxLines: 2,
                          ),
                          Text(item.catgeory),
                          Text(item.price,
                            style: TextStyle(color: Colors.red),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        ); 

I got error : Another exception was thrown: A RenderFlex overflowed by 7.3 pixels on the right.

AnyOne can help?


Solution

  • Just wrap your container with Expanded and use flex property as per your design and let me know its working or not

     return Expanded(
          child: Container(
            child: GestureDetector(
              onTap: () {
                // .......
              },
              child: Container(
                color: Colors.transparent,
                child: Row(
                  children: <Widget>[
                    Padding(
                        padding: EdgeInsets.only(top: 15, bottom: 15),
                        child: Container(
                          width: 2,
                          color: Color(0XFF2B9FDC),
                        )),
                    Padding(
                      padding: EdgeInsets.only(left: 15),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: <Widget>[
                          Text( item.name,
                            overflow: TextOverflow.ellipsis,
                            maxLines: 2,
                          ),
                          Text(item.catgeory),
                          Text(item.price,
                            style: TextStyle(color: Colors.red),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ),
          ),
        );