0

I have the following issue enter image description here

I'm trying to get the text to wrap under the dog type, I tried to wrap the text, flexible but it's not working it's in a row not sure why it's not working here is my code

Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Row(
                children: [
                  const Padding(
                    padding: EdgeInsets.only(right: 8.0, bottom: 4.0),
                    child: FaIcon(
                      FontAwesomeIcons.cubes,
                      size: 24,
                      color: primaryColor,
                    ),
                  ),
                  const Text(
                    'Dog Type: ',
                    style: AppStyles.dogProfileBodyLabelStyle,
                    overflow: TextOverflow.ellipsis,
                  ),
                  Text(
                    dogInfo.dogType!.join(", "),
                    style: AppStyles.dogProfileBodyTextStyle,
                    maxLines: 5,
                    softWrap: true,
                    overflow: TextOverflow.ellipsis,
                  ),
                ],
              ),
              
            ],
          ),

To be clear I want it to wrap under the Dog Type, not like the following enter image description here

Almog
  • 2,639
  • 6
  • 30
  • 59

3 Answers3

1

Try below code hope its help to you.Try to add your Inside Row widgets wrap it with Expanded or Flexible refer my answer here or here or here hope its helpful to you

Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          children: [
            Padding(
              padding: EdgeInsets.only(right: 8.0, bottom: 4.0),
              child: Icon(
                Icons.add,
                size: 24,
              ),
            ),
            Text(
            'Dog Type: ',
            overflow: TextOverflow.ellipsis,
          ),
            Expanded(
              child: Text(
                'dogInfo.dogType!.join(", ")dogInfo.dogType!.join(", ")',
                maxLines: 5,
                softWrap: true,
                overflow: TextOverflow.ellipsis,
              ),
            ),
          ],
        ),
      ],
    ),

Result screen->enter image description here

Ravindra S. Patil
  • 11,757
  • 3
  • 13
  • 40
0

Wrap

Text(
  dogInfo.dogType!.join(", "),
  ...
)

in an Expanded or Flexible widget:

Expanded(
  child: Text(
    dogInfo.dogType!.join(", "),
    ...
  ),
)
iDecode
  • 22,623
  • 19
  • 99
  • 186
0
Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            children: [
              const Padding(
                padding: EdgeInsets.only(right: 8.0, bottom: 4.0),
                child: FaIcon(
                  FontAwesomeIcons.cubes,
                  size: 24,
                  color: primaryColor,
                ),
              ),
              const Text(
                'Dog Type: ',
                style: AppStyles.dogProfileBodyLabelStyle,
                overflow: TextOverflow.ellipsis,
              ),
              Expanded(           //Wrap Text Widget with Expanded Widget
                child: Text(
                       dogInfo.dogType!.join(", "),
                       style: AppStyles.dogProfileBodyTextStyle,
                       maxLines: 5,
                       softWrap: true,
                       overflow: TextOverflow.ellipsis,
                    ),
              ),
            ],
          ),
          
        ],
      ),

or Use RichText Widget..

RichText(
                    text: TextSpan(
                        style: Theme.of(context).textTheme.bodyText1,
                        children: [
                          const TextSpan(text: 'Dog Type: '),
                          TextSpan(
                            text: dogInfo.dogType!.join(", "),
                            style:
                                const TextStyle(color: Color(0xFF003764)),
                          )
                        ]),
                  ),
Zeeshan Ayaz
  • 858
  • 6
  • 11