【问题标题】:How to put one text below the other? - Flutter如何将一个文本放在另一个文本下方? - 颤振
【发布时间】:2021-11-24 23:21:21
【问题描述】:

我想将这 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,
                                  );

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

【问题讨论】:

    标签: android flutter dart mobile


    【解决方案1】:

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

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

    【讨论】:

      【解决方案2】:

      您可以使用三引号

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

      您可以参考此链接了解更多信息:https://api.dartlang.org/stable/2.5.0/dart-core/String-class.html

      【讨论】:

        【解决方案3】:

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

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

        【讨论】:

          猜你喜欢
          • 2021-10-02
          • 2015-09-25
          • 1970-01-01
          • 2018-12-16
          • 2021-10-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多