0
 Widget commonText(
        {required String text, double? size, FontWeight? fontWeight, Color? color}) {
      return Text(text,
        style: TextStyle(
          fontSize: size,
          color: color ?? const Color(0xFF828282),
          fontWeight: fontWeight ?? FontWeight.bold,
          overflow: TextOverflow.ellipsis
      ),);

I use it with listTitile wrap it with row

This is what I get

this is first row i create

Row(
  children: <Widget>[
    Expanded(
      child: ListTile(
          contentPadding: EdgeInsets.zero,
          dense: true,
          horizontalTitleGap: 4,
          minVerticalPadding: 0,
          leading: CircleAvatar(
            radius: 17,
            backgroundImage: NetworkImage(userImage ??
                ("https://cambodiaict.net/wp-content/uploads/2019/12/computer-icons-user-profile-google-account-photos-icon-account.jpg")),
          ),
          title: Text(firstName.toString() + " " + lastName.toString(),
            style: const TextStyle(
                fontWeight: FontWeight.w600,
                overflow: TextOverflow.ellipsis,
                color: Colors.black,
                fontSize: 16,
                letterSpacing: 0.1

            ),),

i use row to wrap text and icons inside

          subtitle: Row(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  const Padding(
                    padding: EdgeInsets.only(right: 2.0),
                    child: ImageIcon(
                        AssetImage(
                          'assets/images/hashtag.png',
                        ),
                        size: 12,
                        color: Color(0xFF828282)),
                  ),
                  commonText(text: uRoomNumber.toString(), size: 12),

                ],
              ),
              const SizedBox(width: 10,),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(right: 2.0),
                    child: const ImageIcon(
                        AssetImage('assets/images/location.png'),
                        size: 12, color: Color(0xFF828282)),
                  ),
                  commonText(text: uLocation.toString(), size: 12),
                ],
              ),
            ],
          )
      ),
    ),

this is the problem i want it to not overflowing

    Container(
      margin: const EdgeInsets.only(bottom: 16, right: 16),
      child: ExtendedText(
        "#" + userNumber.toString().toUpperCase(),
        style: TextStyle(
            fontSize: 14,
            overflow: TextOverflow.ellipsis,
            fontFamily: 'quicksand_bold',
            fontWeight: FontWeight.w600,
            color: AppColor.inactiveText
        ),
        maxLines: 1,
        overflow: TextOverflow.ellipsis,
        overflowWidget: const TextOverflowWidget(
          child: Text("...",
            style: TextStyle(
              fontWeight: FontWeight.w600,
              color: Colors.black,
              fontSize: 16,
            ),
          ),
          position: TextOverflowPosition.start,

        ),
      ),
    )
  ],
);

This what i have tried so far to not make text overflowing each other, i use row {list title sub title,} with container and inside container is another text. inside subtitle is text and icons.

6
  • Try wrapping your text inside Flexible Commented Jul 21, 2022 at 8:05
  • that would be hashsize, because i use list title and another text, wrap it with row Commented Jul 21, 2022 at 8:06
  • wrap the parent of this widget with a flexible widget Commented Jul 21, 2022 at 8:27
  • i have tried, not working! Commented Jul 21, 2022 at 8:41
  • Can you include an image what are you trying to archive, Commented Jul 21, 2022 at 8:55

3 Answers 3

1

Wrap your inner Row with Expanded and commonText Text with Flexible widget

Widget commonText(
  {required String text,
  double? size,
  FontWeight? fontWeight,
  Color? color}) {
return Flexible(
  child: Text(
    text,
    style: TextStyle(
        fontSize: size,
        color: color ?? const Color(0xFF828282),
        fontWeight: fontWeight ?? FontWeight.bold,
        overflow: TextOverflow.ellipsis),
  ),
);
}

And

subtitle: Row(
children: [
  Expanded(
    child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
      ...
        commonText(...),
      ],
    ),
  ),
  const SizedBox(
    width: 10,
  ),
  Expanded(
    child: Row(
      mainAxisAlignment: MainAxisAlignment.center,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: <Widget>[
        /...
        commonText(...),
      ],
    ),
  ),
],
)),
Sign up to request clarification or add additional context in comments.

2 Comments

thank you this is working well! i just need a little align and all good
Glad to help you out, you can check more Row
0

For the tile you are making i would suggest you to use ListTile

ListTile(
  leading: //image,
  title: //rothe chan,
  subtitle: Row(
    children: [
      //icon, 
      Expanded(child: //61dd...),
    ]
  ),
)

Comments

0
          Row( 
          children:<Widget>[   

           CircleAvatar( 
           radius: 17,
           backgroundImage: NetworkImage(url)),

           Expaned(
           child: Text(firstName.toString() + " " + 
             lastName.toString(),
             style: const TextStyle(
             fontWeight: FontWeight.w600,
             overflow: TextOverflow.ellipsis,
             color: Colors.black,
             fontSize: 16,
             letterSpacing: 0.1
         ),),)   ] );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.