如何将一个文本放在另一个文本下面? - 颤振

How to put one text below the other? - Flutter

我想把这4篇文章整理成一个专栏。问题是它们是连续显示的。

AlertDialog alert = AlertDialog(
                                    title: Text("Informações"),
                                    content: Text("P - Selvagem ou Aguti"
                                        "p - preto"
                                        "A - Permite a pigmentação"
                                        "a - Inibe a pigmentação (epistático)"),
                                    actions: [
                                      okButton,
                                    ],
                                    backgroundColor: Colors.white,
                                  );

如何将它们一个放在另一个下面?

在新行的字符串中插入“\n”:

"p - preto\nA - Permite a pigmentação\na - Inibe a pigmentação (epistático)"

您可以使用 三引号 :

child: Container(
             AlertDialog alert = AlertDialog(('''
                              Text1
                              Text2
                              Text3''',)
          ),

您也可以使用 \n 换行:

AlertDialog alert = AlertDialog(
                                title: Text("Informações"),
                                content: Text("P - Selvagem ou Aguti\np - preto\nA - Permite a pigmentação\na - Inibe a pigmentação (epistático)"),
                                actions: [
                                  okButton,
                                ],
                                backgroundColor: Colors.white,
                              );

你可以参考这个link了解更多:https://api.dartlang.org/stable/2.5.0/dart-core/String-class.html

如果您想为每一行设置不同的样式,请将对话框的内容包装在列中

    AlertDialog alert = AlertDialog(
                  title: Text("Informações"),
                  content: Column(
                    mainAxisSize: MainAxisSize.min,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text("P - Selvagem ou Aguti"),
                      Text("p - preto"),
                      Text("A - Permite a pigmentação"),
                      Text("a - Inibe a pigmentação (epistático)"),
                    ],
                  ),
                  actions: [
okButton,],
                  backgroundColor: Colors.white,
                );

如果你想对所有文本使用相同的样式,你可以使用 \n 换行

AlertDialog alert =AlertDialog(
              title: Text("Informações"),
              content: Text(
                  "P - Selvagem ou Aguti \n p - preto \n A - Permite a pigmentação \n a - Inibe a pigmentação (epistático)"),
              actions: [
okButton,],
              backgroundColor: Colors.white,
            );