在Row Widget中添加多行。

huangapple go评论59阅读模式
英文:

Add multiple line in Row Widget

问题

I have wrapped 3 Text in Row, but get exceptions. How can I make them displayed multiple line ?

在Row中包装了3个文本,但出现了异常。如何使它们显示为多行?

Error

错误

A RenderFlex overflowed by 26 pixels on the right.
The relevant error-causing widget was
Row

RenderFlex在右侧溢出了26像素。
引发错误的相关小部件是Row。

英文:

I have wrapped 3 Text in Row, but get exceptions. How can I make them displayed multiple line ?

 Row(children: [
     Text("this is text 1 bla bla bla"),
     Text("this is text 2 bla bla bla"),
     Text("this is text 3 bla bla bla"),
    ],),

Error

════════ Exception caught by rendering library ═════════════════════════════════
A RenderFlex overflowed by 26 pixels on the right.
The relevant error-causing widget was
Row

答案1

得分: 0

你可以使用 Flexible 来解决这个问题

      Row(children: [
        Flexible(child: Text("这是文本 1 嗡嗡嗡")),
        Flexible(child: Text("这是文本 2 嗡嗡嗡")),
        Flexible(child: Text("这是文本 3 嗡嗡嗡")),
      ])

或者你可以使用 Wrap 来展示成一个网格

      Wrap(children: [
        Text("这是文本 1 嗡嗡嗡"),
        Text("这是文本 2 嗡嗡嗡"),
        Text("这是文本 3 嗡嗡嗡"),
      ])
英文:

You can use Flexible to solve this

      Row(children: [
        Flexible(child: Text("this is text 1 bla bla bla")),
        Flexible(child: Text("this is text 2 bla bla bla")),
        Flexible(child: Text("this is text 3 bla bla bla")),
      ])

Or you can use Wrap to show as a grid

      Wrap(children: [
        Text("this is text 1 bla bla bla"),
        Text("this is text 2 bla bla bla"),
        Text("this is text 3 bla bla bla"),
      ])

huangapple
  • 本文由 发表于 2023年2月20日 00:29:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/75501623.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定