【问题标题】:How to make a new line in Wrap Widget如何在 Wrap Widget 中换行
【发布时间】:2020-07-13 11:07:38
【问题描述】:

我使用 Wrap Widget 来显示聊天消息,我无法在 Wrap Widgets 中显示新行 '\n'

显示短信:

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

提取到列表小部件:

然后将listWidget包裹在Wrap Widget中

Wrap(
  children: listWidgets,
)

但文本小部件 ('\ n') 未按预期运行

是否有人在 Wrap Widget 中有解决方案新行,请帮助

【问题讨论】:

    标签: flutter flutter-layout


    【解决方案1】:

    尝试使用 RichText 小部件:

    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,
                          ),
                        ),
                      ],
                    ),
                  ),
    

    【讨论】:

    【解决方案2】:

    您需要指定Wrap 小部件的direction 属性。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-03
      • 2018-08-09
      • 2021-05-26
      • 1970-01-01
      • 2021-05-29
      • 2023-04-04
      • 1970-01-01
      • 2016-07-25
      相关资源
      最近更新 更多