Home > front end >  how to wrap text if length of string is dynamic? flutter
how to wrap text if length of string is dynamic? flutter

Time:01-08

i am creating a flutter view in which user's location apears:

Padding(
                                    padding: const EdgeInsets.only(
                                        right: 14, left: 14, bottom: 8, top: 8),
                                    child: Row(
                                      children: <Widget>[
                                        Column(
                                          crossAxisAlignment: CrossAxisAlignment
                                              .start,
                                          children: <Widget>[
                                            Text(
                                              AppLocalizations.of('PICKUP'),
                                              style: Theme
                                                  .of(context)
                                                  .textTheme
                                                  .caption!
                                                  .copyWith(
                                                color: Theme
                                                    .of(context)
                                                    .disabledColor,
                                                fontWeight: FontWeight.bold,
                                              ),
                                            ),
                                            SizedBox(
                                              height: 4,
                                            ),
                                            Text(
                                              AppLocalizations.of(
                                                  '${list[index]['from']}'),
                                              style: Theme
                                                  .of(context)
                                                  .textTheme
                                                  .subtitle2!
                                                  .copyWith(
                                                fontWeight: FontWeight.bold,
                                                color: Theme
                                                    .of(context)
                                                    .textTheme
                                                    .headline6!
                                                    .color,
                                              ),
                                            ),
                                          ],
                                        ),
                                      ],
                                    ),
                                  ),

the data here is coming from sql server which contains address. sometimes the addresss is long so it only shows some words and rest of the words overflowed.

what i want whenever there is long adreess it wraps into the next line . but i dont know how to achieve because i am new to flutter. can anyone please help. Thannks in advance <3.

CodePudding user response:

You can wrap your text in Flexible widget

Flexible(
child: 
 Text(
            AppLocalizations.of(
                '${list[index]['from']}'),
                       style: Theme
                       .of(context)
                       .textTheme
                        .subtitle2!
                        .copyWith(
                            fontWeight: FontWeight.bold,
                            color: Theme
                                .of(context)
                                .textTheme
                                .headline6!
                                .color,
                        ),
               ),
)

also you can use this package : https://pub.dev/packages/auto_size_text for manage size of your text.

CodePudding user response:

Wrap text widget in Flexible widget. You can also check this link for text overflow issue.

CodePudding user response:

    Padding(
padding:const EdgeInsets.all(0)
    child:Text("your String")
);
  •  Tags:  
  • Related