Hưng Trịnh
Hưng Trịnh

Reputation: 1047

How to make a new line in Wrap Widget

I use the Wrap Widget to display chat messages, I'm having trouble getting show new line '\n' in Wrap Widgets

show text message:

a *bold*
`highlight`
```pre```
```pre1```
a ```pre2```
a *bold*

Extract to list widget: enter image description here

and then wrap listWidget in Wrap Widget

Wrap(
  children: listWidgets,
)

enter image description here

but the Text widget ('\ n') doesn't go as expected

Does anyone have solution new line in Wrap Widget please help

Upvotes: 0

Views: 666

Answers (2)

Shahmil
Shahmil

Reputation: 341

You need to specify the direction property of your Wrap widget.

Wrap(
   direction: Axis.vertical,
   children: listWidgets,
)

Upvotes: 0

Jim
Jim

Reputation: 7601

Try to use RichText widget:

RichText(
                text: TextSpan(
                  text: '26 Sep 2020\n\n',
                  style: TextStyle(
                    color: Colors.black,
                    fontSize: 12.0,
                  ),
                  children: <TextSpan>[
                    TextSpan(
                      text: 'blablabla',
                      style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.black,
                        fontSize: 16.0,
                      ),
                    ),
                  ],
                ),
              ),

Upvotes: 1

Related Questions